2018-09-27 02:31:05 -05:00
|
|
|
|
import { getApiKeys } from './selectors';
|
|
|
|
|
import { getMultipleMockKeys } from '../__mocks__/apiKeysMock';
|
|
|
|
|
import { ApiKeysState } from 'app/types';
|
|
|
|
|
|
|
|
|
|
describe('API Keys selectors', () => {
|
|
|
|
|
describe('Get API Keys', () => {
|
|
|
|
|
const mockKeys = getMultipleMockKeys(5);
|
|
|
|
|
|
|
|
|
|
it('should return all keys if no search query', () => {
|
2021-03-04 06:20:38 -06:00
|
|
|
|
const mockState: ApiKeysState = { keys: mockKeys, searchQuery: '', hasFetched: false };
|
2018-09-27 02:31:05 -05:00
|
|
|
|
|
|
|
|
|
const keys = getApiKeys(mockState);
|
|
|
|
|
|
|
|
|
|
expect(keys).toEqual(mockKeys);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should filter keys if search query exists', () => {
|
2021-03-04 06:20:38 -06:00
|
|
|
|
const mockState: ApiKeysState = { keys: mockKeys, searchQuery: '5', hasFetched: false };
|
2018-09-27 02:31:05 -05:00
|
|
|
|
|
|
|
|
|
const keys = getApiKeys(mockState);
|
|
|
|
|
|
|
|
|
|
expect(keys.length).toEqual(1);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|