From c1dca1c8d59105153e52c3d5aaa821d2cc5bf0eb Mon Sep 17 00:00:00 2001 From: Pavel Zavora Date: Sun, 21 Jun 2020 08:44:51 +0200 Subject: [PATCH] fix(worker/timeSeriesToTableGraph): add test --- .../jobs/timeSeriesToTableGraph.test.tsx | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 ui/test/worker/jobs/timeSeriesToTableGraph.test.tsx diff --git a/ui/test/worker/jobs/timeSeriesToTableGraph.test.tsx b/ui/test/worker/jobs/timeSeriesToTableGraph.test.tsx new file mode 100644 index 000000000..d60a7484a --- /dev/null +++ b/ui/test/worker/jobs/timeSeriesToTableGraph.test.tsx @@ -0,0 +1,46 @@ +import {timeSeriesToTableGraphWork} from 'src/worker/jobs/timeSeriesToTableGraph' + +describe('worker/jobs/timeSeriesToTableGraph', () => { + it('generates unique column names', () => { + const testData = [ + { + response: { + results: [ + { + statement_id: 0, + series: [ + {name: 'cpu', columns: ['time', 'count'], values: [[0, 495]]}, + ], + }, + ], + uuid: '76c20d6b-6803-44b9-a292-213d8b298aa5', + }, + }, + { + response: { + results: [ + { + statement_id: 0, + series: [ + {name: 'cpu', columns: ['time', 'count'], values: [[0, 495]]}, + ], + }, + ], + uuid: '76c20d6b-6803-44b9-a292-213d8b298aa5', + }, + }, + ] + const result = timeSeriesToTableGraphWork(testData) + expect(result).toEqual({ + data: [ + ['time', 'cpu.count', 'cpu.count_2'], // the second column is renamed + [0, 495, 495], + ], + sortedLabels: [ + {label: 'cpu.count', responseIndex: 0, seriesIndex: 0}, + {label: 'cpu.count_2', responseIndex: 1, seriesIndex: 0}, + ], + influxQLQueryType: 'DataQuery', + }) + }) +})