Skip to content

Commit

Permalink
removed lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: aribalam <[email protected]>
  • Loading branch information
aribalam committed Sep 20, 2020
1 parent fb67464 commit 5bdec1d
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions pkg/ui/react-app/src/utils/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,26 @@ describe('Utils', () => {
});

describe('URL Params', () => {
const stores: any = [
{
name: 'thanos_sidecar_one:10901',
lastCheck: '2020-09-20T11:35:18.250713478Z',
lastError: null,
labelSets: [
{
labels: [
{
name: 'monitor',
value: 'prometheus_one',
},
],
},
],
minTime: 1600598100000,
maxTime: 9223372036854776000,
},
];

const panels: any = [
{
key: '0',
Expand All @@ -147,6 +167,7 @@ describe('Utils', () => {
useDeduplication: true,
usePartialResponse: false,
type: PanelType.Graph,
storeMatches: [],
},
},
{
Expand All @@ -161,11 +182,12 @@ describe('Utils', () => {
useDeduplication: false,
usePartialResponse: true,
type: PanelType.Table,
storeMatches: stores,
},
},
];
const query =
'?g0.expr=rate(node_cpu_seconds_total%7Bmode%3D%22system%22%7D%5B1m%5D)&g0.tab=0&g0.stacked=0&g0.range_input=1h&g0.max_source_resolution=raw&g0.deduplicate=1&g0.partial_response=0&g0.end_input=2019-10-25%2023%3A37%3A00&g0.moment_input=2019-10-25%2023%3A37%3A00&g1.expr=node_filesystem_avail_bytes&g1.tab=1&g1.stacked=0&g1.range_input=1h&g1.max_source_resolution=auto&g1.deduplicate=0&g1.partial_response=1';
'?g0.expr=rate(node_cpu_seconds_total%7Bmode%3D%22system%22%7D%5B1m%5D)&g0.tab=0&g0.stacked=0&g0.range_input=1h&g0.max_source_resolution=raw&g0.deduplicate=1&g0.partial_response=0&g0.store_matches=%5B%5D&g0.end_input=2019-10-25%2023%3A37%3A00&g0.moment_input=2019-10-25%2023%3A37%3A00&g1.expr=node_filesystem_avail_bytes&g1.tab=1&g1.stacked=0&g1.range_input=1h&g1.max_source_resolution=auto&g1.deduplicate=0&g1.partial_response=1&g1.store_matches=%5B%7B%22name%22%3A%22thanos_sidecar_one%3A10901%22%2C%22lastCheck%22%3A%222020-09-20T11%3A35%3A18.250713478Z%22%2C%22lastError%22%3Anull%2C%22labelSets%22%3A%5B%7B%22labels%22%3A%5B%7B%22name%22%3A%22monitor%22%2C%22value%22%3A%22prometheus_one%22%7D%5D%7D%5D%2C%22minTime%22%3A1600598100000%2C%22maxTime%22%3A9223372036854776000%7D%5D';

describe('decodePanelOptionsFromQueryString', () => {
it('returns [] when query is empty', () => {
Expand Down Expand Up @@ -204,6 +226,13 @@ describe('Utils', () => {
it('should parse partial_response', () => {
expect(parseOption('partial_response=1')).toEqual({ usePartialResponse: true });
});
it('it should parse store_matches', () => {
expect(
parseOption(
'store_matches=%5B%7B%22name%22%3A%22thanos_sidecar_one%3A10901%22%2C%22lastCheck%22%3A%222020-09-20T11%3A35%3A18.250713478Z%22%2C%22lastError%22%3Anull%2C%22labelSets%22%3A%5B%7B%22labels%22%3A%5B%7B%22name%22%3A%22monitor%22%2C%22value%22%3A%22prometheus_one%22%7D%5D%7D%5D%2C%22minTime%22%3A1600598100000%2C%22maxTime%22%3A9223372036854776000%7D%5D'
)
).toEqual({ storeMatches: stores });
});

describe('step_input', () => {
it('should return step_input parsed if > 0', () => {
Expand Down Expand Up @@ -249,10 +278,11 @@ describe('Utils', () => {
maxSourceResolution: 'raw',
useDeduplication: true,
usePartialResponse: false,
storeMatches: [],
},
})
).toEqual(
'g0.expr=foo&g0.tab=0&g0.stacked=1&g0.range_input=0y&g0.max_source_resolution=raw&g0.deduplicate=1&g0.partial_response=0&g0.step_input=1'
'g0.expr=foo&g0.tab=0&g0.stacked=1&g0.range_input=0y&g0.max_source_resolution=raw&g0.deduplicate=1&g0.partial_response=0&g0.store_matches=%5B%5D&g0.step_input=1'
);
});
});
Expand Down

0 comments on commit 5bdec1d

Please sign in to comment.