Fix dashboardapi adapter and Jest coverage
This commit is contained in:
@@ -5,7 +5,19 @@ jest.mock('../src/specificClass', () => {
|
||||
logger: {
|
||||
warn: jest.fn(),
|
||||
},
|
||||
generateDashB: jest.fn().mockResolvedValue({ dashboard: { title: 'ok' } }),
|
||||
generateDashboardsForGraph: jest.fn(() => [{
|
||||
dashboard: { title: 'ok' },
|
||||
nodeId: 'child-node-id',
|
||||
softwareType: 'measurement',
|
||||
uid: 'child-uid',
|
||||
title: 'ok',
|
||||
}]),
|
||||
buildUpsertRequest: jest.fn(({ dashboard, folderId, overwrite }) => ({
|
||||
dashboard,
|
||||
folderId,
|
||||
overwrite,
|
||||
})),
|
||||
grafanaUpsertUrl: jest.fn(() => 'http://grafana:3000/api/dashboards/db'),
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -77,7 +89,13 @@ describe('dashboardAPI nodeClass', () => {
|
||||
expect(send).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
topic: 'create',
|
||||
payload: { dashboard: { title: 'ok' } },
|
||||
url: 'http://grafana:3000/api/dashboards/db',
|
||||
method: 'POST',
|
||||
payload: {
|
||||
dashboard: { title: 'ok' },
|
||||
folderId: 0,
|
||||
overwrite: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
expect(done).toHaveBeenCalledWith();
|
||||
@@ -109,7 +127,11 @@ describe('dashboardAPI nodeClass', () => {
|
||||
expect(send).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
topic: 'create',
|
||||
payload: { dashboard: { title: 'ok' } },
|
||||
payload: {
|
||||
dashboard: { title: 'ok' },
|
||||
folderId: 0,
|
||||
overwrite: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
expect(done).toHaveBeenCalledWith();
|
||||
@@ -145,7 +167,11 @@ describe('dashboardAPI nodeClass', () => {
|
||||
expect(send).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
topic: 'create',
|
||||
payload: { dashboard: { title: 'ok' } },
|
||||
payload: {
|
||||
dashboard: { title: 'ok' },
|
||||
folderId: 0,
|
||||
overwrite: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
expect(done).toHaveBeenCalledWith();
|
||||
|
||||
Reference in New Issue
Block a user