Chore: Fixes various strict null errors (#21763)

* Chore: Removes strict null checks in ReducerTester

* Chore: Fixes strict null errors in ConfigureStore

* Chore: Fixes strict null errors in reducer tests

* Chore: Fixes strict null errors in reducers tests

* Chore: Fixes strict null errors in reducers tests

* Chore: Fixes strict null errors in toggleLogActionsMiddleware

* Chore: Fixes strict null errors in navModelReducer

* Core: Fixes strict null errors in public/app/features/admin/state

* Chore: Fixes strict null errors in public/app/features/dashboard/state/reducers.test.ts

* Chore: Fixes strict null errors in public/app/features/explore/state/reducers.test.ts

* Chore: Fixes strict null errors in public/app/features/datasources/state/reducers.test.ts

* Chore: Fixes strict null errors in public/e2e-test/scenarios/templating/templatevariables-crud.test.ts

* Chore: Fixes strict null errors in public/app/features/dashboard/containers/DashboardPage.test.tsx
This commit is contained in:
Hugo Häggmark
2020-01-28 09:13:56 +01:00
committed by GitHub
parent 6c32a4c0ab
commit 044bea0935
15 changed files with 181 additions and 152 deletions

View File

@@ -4,22 +4,22 @@ import {
dataSourceMetaLoaded,
dataSourcePluginsLoad,
dataSourcePluginsLoaded,
dataSourceSettingsReducer,
dataSourcesLoaded,
dataSourcesReducer,
initDataSourceSettingsFailed,
initDataSourceSettingsSucceeded,
initialDataSourceSettingsState,
initialState,
setDataSourceName,
setDataSourcesLayoutMode,
setDataSourcesSearchQuery,
setDataSourceTypeSearchQuery,
setIsDefault,
dataSourceSettingsReducer,
initialDataSourceSettingsState,
initDataSourceSettingsSucceeded,
initDataSourceSettingsFailed,
} from './reducers';
import { getMockDataSource, getMockDataSources } from '../__mocks__/dataSourcesMocks';
import { LayoutModes } from 'app/core/components/LayoutSelector/LayoutSelector';
import { DataSourcesState, DataSourceSettingsState } from 'app/types';
import { DataSourceSettingsState, DataSourcesState } from 'app/types';
import { PluginMeta, PluginMetaInfo, PluginType } from '@grafana/data';
import { GenericDataSourcePlugin } from '../settings/PluginSettings';
@@ -42,7 +42,7 @@ describe('dataSourcesReducer', () => {
it('then state should be correct', () => {
const dataSources = getMockDataSources(0);
reducerTester()
reducerTester<DataSourcesState>()
.givenReducer(dataSourcesReducer, initialState)
.whenActionIsDispatched(dataSourcesLoaded(dataSources))
.thenStateShouldEqual({ ...initialState, hasFetched: true, dataSources, dataSourcesCount: 1 });
@@ -53,7 +53,7 @@ describe('dataSourcesReducer', () => {
it('then state should be correct', () => {
const dataSource = getMockDataSource();
reducerTester()
reducerTester<DataSourcesState>()
.givenReducer(dataSourcesReducer, initialState)
.whenActionIsDispatched(dataSourceLoaded(dataSource))
.thenStateShouldEqual({ ...initialState, dataSource });
@@ -62,7 +62,7 @@ describe('dataSourcesReducer', () => {
describe('when setDataSourcesSearchQuery is dispatched', () => {
it('then state should be correct', () => {
reducerTester()
reducerTester<DataSourcesState>()
.givenReducer(dataSourcesReducer, initialState)
.whenActionIsDispatched(setDataSourcesSearchQuery('some query'))
.thenStateShouldEqual({ ...initialState, searchQuery: 'some query' });
@@ -73,7 +73,7 @@ describe('dataSourcesReducer', () => {
it('then state should be correct', () => {
const layoutMode: LayoutModes = LayoutModes.Grid;
reducerTester()
reducerTester<DataSourcesState>()
.givenReducer(dataSourcesReducer, initialState)
.whenActionIsDispatched(setDataSourcesLayoutMode(layoutMode))
.thenStateShouldEqual({ ...initialState, layoutMode: LayoutModes.Grid });
@@ -84,7 +84,7 @@ describe('dataSourcesReducer', () => {
it('then state should be correct', () => {
const state: DataSourcesState = { ...initialState, plugins: [mockPlugin()] };
reducerTester()
reducerTester<DataSourcesState>()
.givenReducer(dataSourcesReducer, state)
.whenActionIsDispatched(dataSourcePluginsLoad())
.thenStateShouldEqual({ ...initialState, isLoadingDataSources: true });
@@ -96,7 +96,7 @@ describe('dataSourcesReducer', () => {
const dataSourceTypes = [mockPlugin()];
const state: DataSourcesState = { ...initialState, isLoadingDataSources: true };
reducerTester()
reducerTester<DataSourcesState>()
.givenReducer(dataSourcesReducer, state)
.whenActionIsDispatched(dataSourcePluginsLoaded({ plugins: dataSourceTypes, categories: [] }))
.thenStateShouldEqual({ ...initialState, plugins: dataSourceTypes, isLoadingDataSources: false });
@@ -105,7 +105,7 @@ describe('dataSourcesReducer', () => {
describe('when setDataSourceTypeSearchQuery is dispatched', () => {
it('then state should be correct', () => {
reducerTester()
reducerTester<DataSourcesState>()
.givenReducer(dataSourcesReducer, initialState)
.whenActionIsDispatched(setDataSourceTypeSearchQuery('type search query'))
.thenStateShouldEqual({ ...initialState, dataSourceTypeSearchQuery: 'type search query' });
@@ -116,7 +116,7 @@ describe('dataSourcesReducer', () => {
it('then state should be correct', () => {
const dataSourceMeta = mockPlugin();
reducerTester()
reducerTester<DataSourcesState>()
.givenReducer(dataSourcesReducer, initialState)
.whenActionIsDispatched(dataSourceMetaLoaded(dataSourceMeta))
.thenStateShouldEqual({ ...initialState, dataSourceMeta });
@@ -125,19 +125,19 @@ describe('dataSourcesReducer', () => {
describe('when setDataSourceName is dispatched', () => {
it('then state should be correct', () => {
reducerTester()
reducerTester<DataSourcesState>()
.givenReducer(dataSourcesReducer, initialState)
.whenActionIsDispatched(setDataSourceName('some name'))
.thenStateShouldEqual({ ...initialState, dataSource: { name: 'some name' } });
.thenStateShouldEqual({ ...initialState, dataSource: { name: 'some name' } } as DataSourcesState);
});
});
describe('when setIsDefault is dispatched', () => {
it('then state should be correct', () => {
reducerTester()
reducerTester<DataSourcesState>()
.givenReducer(dataSourcesReducer, initialState)
.whenActionIsDispatched(setIsDefault(true))
.thenStateShouldEqual({ ...initialState, dataSource: { isDefault: true } });
.thenStateShouldEqual({ ...initialState, dataSource: { isDefault: true } } as DataSourcesState);
});
});
});