mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-02 05:52:46 +02:00
68313da412
* Typescript config setup * Add type annotations to components * Further type additions * And more... * Add types to actions * Add types to templates * Further type checks * Further type additons * Install fuse latest * Housekeeping * Remove old type definitions * Fix remaning type issues * Fix some failing tests * Remove types workflow * Fix failing unit tests * Resolve back space event regression * Convert cypress files to .ts * Fix eslint issues * Remove cachebusting urls * Resolve delete button bug * Resolve regression bugs * Fix lint script * Fix lint workflow * Pass args instead of object to keyboard handlers * Flatten misc reducer * Resolve keyboad action test failures * Use Pick instead of Partial * Use interfaces in action tests * Update firefox image * Incorporate #791 * Incorporate #788
61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import { createStore } from 'redux';
|
|
import { expect } from 'chai';
|
|
import rootReducer from '.';
|
|
import groups from './groups';
|
|
import choices from './choices';
|
|
import items from './items';
|
|
import loading from './loading';
|
|
|
|
describe('reducers/rootReducer', () => {
|
|
const store = createStore(rootReducer);
|
|
|
|
it('returns expected reducers', () => {
|
|
const state = store.getState();
|
|
|
|
expect(state.groups).to.equal(groups(undefined, {} as any));
|
|
expect(state.choices).to.equal(choices(undefined, {} as any));
|
|
expect(state.items).to.equal(items(undefined, {} as any));
|
|
expect(state.loading).to.equal(loading(undefined, {} as any));
|
|
});
|
|
|
|
describe('CLEAR_ALL', () => {
|
|
it('resets state', () => {
|
|
const output = rootReducer(
|
|
{
|
|
items: [1, 2, 3],
|
|
groups: [1, 2, 3],
|
|
choices: [1, 2, 3],
|
|
},
|
|
{
|
|
type: 'CLEAR_ALL',
|
|
},
|
|
);
|
|
|
|
expect(output).to.eql({
|
|
items: [],
|
|
groups: [],
|
|
choices: [],
|
|
loading: false,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('RESET_TO', () => {
|
|
it('replaces state with given state', () => {
|
|
const output = rootReducer(
|
|
{
|
|
items: [1, 2, 3],
|
|
groups: [1, 2, 3],
|
|
choices: [1, 2, 3],
|
|
},
|
|
{
|
|
type: 'RESET_TO',
|
|
state: {},
|
|
},
|
|
);
|
|
|
|
expect(output).to.eql({});
|
|
});
|
|
});
|
|
});
|