Debian Codegraph @

packages/time-series/lib/commands/RANGE.spec.ts

raw
1 import { strict as assert } from 'assert';
2 import testUtils, { GLOBAL } from '../test-utils';
3 import { transformArguments } from './RANGE';
4 import { TimeSeriesAggregationType } from '.';
5
6 describe('RANGE', () => {
7 it('transformArguments', () => {
8 assert.deepEqual(
9 transformArguments('key', '-', '+', {
10 FILTER_BY_TS: [0],
11 FILTER_BY_VALUE: {
12 min: 1,
13 max: 2
14 },
15 COUNT: 1,
16 ALIGN: '-',
17 AGGREGATION: {
18 type: TimeSeriesAggregationType.AVERAGE,
19 timeBucket: 1
20 }
21 }),
22 ['TS.RANGE', 'key', '-', '+', 'FILTER_BY_TS', '0', 'FILTER_BY_VALUE',
23 '1', '2', 'COUNT', '1', 'ALIGN', '-', 'AGGREGATION', 'AVG', '1']
24 );
25 });
26
27 testUtils.testWithClient('client.ts.range', async client => {
28 await client.ts.add('key', 1, 2);
29
30 assert.deepEqual(
31 await client.ts.range('key', '-', '+'),
32 [{
33 timestamp: 1,
34 value: 2
35 }]
36 );
37 }, GLOBAL.SERVERS.OPEN);
38 });