Chore: fix type errors in tests (#63270)

* fix any's in tests

* fix more any's in tests

* more test type fixes

* fixing any's in tests part 3

* more test type fixes

* fixing test any's p5

* some tidy up

* fix template_srv
This commit is contained in:
Ashley Harrison
2023-02-14 16:46:42 +01:00
committed by GitHub
parent 4b0faf1c9e
commit f8d89eff56
139 changed files with 675 additions and 1080 deletions

View File

@@ -12,8 +12,8 @@ import { SaveDashboardForm } from './SaveDashboardForm';
const prepareDashboardMock = (
timeChanged: boolean,
variableValuesChanged: boolean,
resetTimeSpy: any,
resetVarsSpy: any
resetTimeSpy: jest.Mock,
resetVarsSpy: jest.Mock
) => {
const json = {
title: 'name',
@@ -29,12 +29,12 @@ const prepareDashboardMock = (
meta: {},
...json,
getSaveModelClone: () => json,
};
} as unknown as DashboardModel;
};
const renderAndSubmitForm = async (dashboard: any, submitSpy: any) => {
const renderAndSubmitForm = async (dashboard: DashboardModel, submitSpy: jest.Mock) => {
render(
<SaveDashboardForm
dashboard={dashboard as DashboardModel}
dashboard={dashboard}
onCancel={() => {}}
onSuccess={() => {}}
onSubmit={async (jsonModel) => {
@@ -62,14 +62,14 @@ describe('SaveDashboardAsForm', () => {
it('renders switches when variables or timerange', () => {
render(
<SaveDashboardForm
dashboard={prepareDashboardMock(true, true, jest.fn(), jest.fn()) as any}
dashboard={prepareDashboardMock(true, true, jest.fn(), jest.fn())}
onCancel={() => {}}
onSuccess={() => {}}
onSubmit={async () => {
return {};
}}
saveModel={{
clone: prepareDashboardMock(true, true, jest.fn(), jest.fn()) as any,
clone: prepareDashboardMock(true, true, jest.fn(), jest.fn()),
diff: {},
diffCount: 0,
hasChanges: true,
@@ -99,7 +99,7 @@ describe('SaveDashboardAsForm', () => {
const resetVarsSpy = jest.fn();
const submitSpy = jest.fn();
await renderAndSubmitForm(prepareDashboardMock(false, false, resetTimeSpy, resetVarsSpy) as any, submitSpy);
await renderAndSubmitForm(prepareDashboardMock(false, false, resetTimeSpy, resetVarsSpy), submitSpy);
expect(resetTimeSpy).not.toBeCalled();
expect(resetVarsSpy).not.toBeCalled();
@@ -112,7 +112,7 @@ describe('SaveDashboardAsForm', () => {
const resetTimeSpy = jest.fn();
const resetVarsSpy = jest.fn();
const submitSpy = jest.fn();
await renderAndSubmitForm(prepareDashboardMock(true, true, resetTimeSpy, resetVarsSpy) as any, submitSpy);
await renderAndSubmitForm(prepareDashboardMock(true, true, resetTimeSpy, resetVarsSpy), submitSpy);
expect(resetTimeSpy).toBeCalledTimes(0);
expect(resetVarsSpy).toBeCalledTimes(0);