|
1 | | -const fs = require('fs'); |
2 | | -const DashboardBuilder = require('./lib/DashboardBuilder'); |
| 1 | +const fs = require("fs"); |
| 2 | +const DashboardBuilder = require("./lib/DashboardBuilder"); |
3 | 3 | const builder = new DashboardBuilder() |
4 | 4 |
|
5 | | -function runTest(dashboard) { |
| 5 | +function getDashboard(dashboard) { |
6 | 6 | const options = { |
7 | 7 | table: "basicrum_friends_webperf_rum_events", |
8 | 8 | datasourceUid: "A0Wl5Mc4z", |
9 | 9 | filterMap: { |
10 | 10 | "hosts":"testHosts", |
11 | 11 | }, |
12 | 12 | } |
13 | | - |
| 13 | + |
14 | 14 | builder.build(dashboard, options); |
15 | 15 |
|
16 | | - const expected = JSON.parse(fs.readFileSync(`./testdata/dashboards/${dashboard}.json`, { encoding: 'utf8', flag: 'r' })); |
17 | | - const actual = JSON.parse(fs.readFileSync(`./build/dashboards/${dashboard}.json`, { encoding: 'utf8', flag: 'r' })); |
18 | | - expect(actual).toMatchObject(expected); |
| 16 | + return JSON.parse(fs.readFileSync(`./build/dashboards/${dashboard}.json`, { encoding: "utf8", flag: "r" })); |
19 | 17 | } |
20 | 18 |
|
21 | | -test('build General dashboard should be as expected', () => { |
22 | | - runTest('General') |
| 19 | +test("Test General dashboard should be as expected", () => { |
| 20 | + const generalDashboard = getDashboard("General"); |
| 21 | + |
| 22 | + expect(34).toBe(generalDashboard.panels.length); |
23 | 23 | }); |
24 | 24 |
|
25 | | -test('build Metrics dashboard should be as expected', () => { |
26 | | - runTest('Metrics') |
| 25 | +test("Test Metrics dashboard should be as expected", () => { |
| 26 | + const metricsDashboard = getDashboard("Metrics"); |
| 27 | + |
| 28 | + expect(4).toBe(metricsDashboard.panels.length); |
27 | 29 | }); |
28 | 30 |
|
29 | | -test('build Summary dashboard should be as expected', () => { |
30 | | - runTest('Summary') |
| 31 | +test("Test Summary dashboard should be as expected", () => { |
| 32 | + const summaryDashboard = getDashboard("Summary"); |
| 33 | + |
| 34 | + expect(14).toBe(summaryDashboard.panels.length); |
31 | 35 | }); |
0 commit comments