2020-01-13 01:03:22 -06:00
|
|
|
|
import { apiKeysLoaded, apiKeysReducer, initialApiKeysState, setSearchQuery } from './reducers';
|
2018-09-27 02:31:05 -05:00
|
|
|
|
import { getMultipleMockKeys } from '../__mocks__/apiKeysMock';
|
2020-01-13 01:03:22 -06:00
|
|
|
|
import { reducerTester } from '../../../../test/core/redux/reducerTester';
|
|
|
|
|
import { ApiKeysState } from '../../../types';
|
2018-09-27 02:31:05 -05:00
|
|
|
|
|
|
|
|
|
describe('API Keys reducer', () => {
|
|
|
|
|
it('should set keys', () => {
|
2020-01-13 01:03:22 -06:00
|
|
|
|
reducerTester<ApiKeysState>()
|
|
|
|
|
.givenReducer(apiKeysReducer, { ...initialApiKeysState })
|
|
|
|
|
.whenActionIsDispatched(apiKeysLoaded(getMultipleMockKeys(4)))
|
|
|
|
|
.thenStateShouldEqual({
|
|
|
|
|
...initialApiKeysState,
|
|
|
|
|
keys: getMultipleMockKeys(4),
|
|
|
|
|
hasFetched: true,
|
|
|
|
|
});
|
2018-09-27 02:31:05 -05:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should set search query', () => {
|
2020-01-13 01:03:22 -06:00
|
|
|
|
reducerTester<ApiKeysState>()
|
|
|
|
|
.givenReducer(apiKeysReducer, { ...initialApiKeysState })
|
|
|
|
|
.whenActionIsDispatched(setSearchQuery('test query'))
|
|
|
|
|
.thenStateShouldEqual({
|
|
|
|
|
...initialApiKeysState,
|
|
|
|
|
searchQuery: 'test query',
|
|
|
|
|
});
|
2018-09-27 02:31:05 -05:00
|
|
|
|
});
|
|
|
|
|
});
|