mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
59 lines
1.7 KiB
TypeScript
59 lines
1.7 KiB
TypeScript
import { reducerTester } from '../../../../test/core/redux/reducerTester';
|
|
import { ApiKeysState } from '../../../types';
|
|
import { getMultipleMockKeys } from '../__mocks__/apiKeysMock';
|
|
|
|
import {
|
|
apiKeysLoaded,
|
|
apiKeysReducer,
|
|
includeExpiredToggled,
|
|
initialApiKeysState,
|
|
isFetching,
|
|
setSearchQuery,
|
|
} from './reducers';
|
|
|
|
describe('API Keys reducer', () => {
|
|
it('should set keys', () => {
|
|
reducerTester<ApiKeysState>()
|
|
.givenReducer(apiKeysReducer, { ...initialApiKeysState })
|
|
.whenActionIsDispatched(
|
|
apiKeysLoaded({ keys: getMultipleMockKeys(4), keysIncludingExpired: getMultipleMockKeys(6) })
|
|
)
|
|
.thenStateShouldEqual({
|
|
...initialApiKeysState,
|
|
keys: getMultipleMockKeys(4),
|
|
keysIncludingExpired: getMultipleMockKeys(6),
|
|
hasFetched: true,
|
|
});
|
|
});
|
|
|
|
it('should set search query', () => {
|
|
reducerTester<ApiKeysState>()
|
|
.givenReducer(apiKeysReducer, { ...initialApiKeysState })
|
|
.whenActionIsDispatched(setSearchQuery('test query'))
|
|
.thenStateShouldEqual({
|
|
...initialApiKeysState,
|
|
searchQuery: 'test query',
|
|
});
|
|
});
|
|
|
|
it('should toggle the includeExpired state', () => {
|
|
reducerTester<ApiKeysState>()
|
|
.givenReducer(apiKeysReducer, { ...initialApiKeysState })
|
|
.whenActionIsDispatched(includeExpiredToggled())
|
|
.thenStateShouldEqual({
|
|
...initialApiKeysState,
|
|
includeExpired: true,
|
|
});
|
|
});
|
|
|
|
it('should set state when fetching', () => {
|
|
reducerTester<ApiKeysState>()
|
|
.givenReducer(apiKeysReducer, { ...initialApiKeysState })
|
|
.whenActionIsDispatched(isFetching())
|
|
.thenStateShouldEqual({
|
|
...initialApiKeysState,
|
|
hasFetched: false,
|
|
});
|
|
});
|
|
});
|