fix unit tests

This commit is contained in:
Ashley Harrison
2024-02-02 17:30:05 +00:00
parent 1f9687598f
commit 72cd81c803
3 changed files with 26 additions and 26 deletions
-3
View File
@@ -3998,9 +3998,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "4"],
[0, 0, 0, "Styles should be written using objects.", "5"]
],
"public/app/features/manage-dashboards/state/actions.test.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/features/manage-dashboards/state/actions.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
@@ -1,7 +1,7 @@
import { thunkTester } from 'test/core/thunk/thunkTester';
import { DataSourceInstanceSettings, ThresholdsMode } from '@grafana/data';
import { BackendSrv, setBackendSrv } from '@grafana/runtime';
import { BackendSrv, BackendSrvRequest, setBackendSrv } from '@grafana/runtime';
import { defaultDashboard, FieldColorModeId } from '@grafana/schema';
import { getLibraryPanel } from 'app/features/library-panels/state/api';
@@ -40,14 +40,11 @@ describe('importDashboard', () => {
},
};
let postArgs: any;
let fetchArgs: unknown;
setBackendSrv({
post: (url, args) => {
postArgs = args;
return Promise.resolve({
importedUrl: '/my/dashboard',
});
fetch: (options: BackendSrvRequest) => {
fetchArgs = options;
},
} as BackendSrv);
@@ -70,22 +67,26 @@ describe('importDashboard', () => {
.givenThunk(importDashboard)
.whenThunkIsDispatched(form);
expect(postArgs).toEqual({
dashboard: {
title: 'Asda',
uid: '12',
},
folderUid: '5v6e5VH4z',
inputs: [
{
name: 'ds-name',
pluginId: 'prometheus',
type: 'datasource',
value: 'ds-uid',
expect(fetchArgs).toEqual(
expect.objectContaining({
data: {
dashboard: {
title: 'Asda',
uid: '12',
},
folderUid: '5v6e5VH4z',
inputs: [
{
name: 'ds-name',
pluginId: 'prometheus',
type: 'datasource',
value: 'ds-uid',
},
],
overwrite: true,
},
],
overwrite: true,
});
})
);
});
});
+3 -1
View File
@@ -2,7 +2,9 @@ import { PayloadAction } from '@reduxjs/toolkit';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
const mockStore = configureMockStore([thunk]);
import { browseDashboardsAPI } from 'app/features/browse-dashboards/api/browseDashboardsAPI';
const mockStore = configureMockStore([thunk, browseDashboardsAPI.middleware]);
export interface ThunkGiven {
givenThunk: (thunkFunction: any) => ThunkWhen;