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
72 lines
1.6 KiB
TypeScript
72 lines
1.6 KiB
TypeScript
import { expect } from 'chai';
|
|
import groups, { defaultState } from './groups';
|
|
|
|
describe('reducers/groups', () => {
|
|
it('should return same state when no action matches', () => {
|
|
expect(groups(defaultState, {} as any)).to.equal(defaultState);
|
|
});
|
|
|
|
describe('when groups do not exist', () => {
|
|
describe('ADD_GROUP', () => {
|
|
it('adds group', () => {
|
|
const id = 1;
|
|
const value = 'Group one';
|
|
const active = true;
|
|
const disabled = false;
|
|
|
|
const expectedResponse = [
|
|
{
|
|
id,
|
|
value,
|
|
active,
|
|
disabled,
|
|
},
|
|
];
|
|
|
|
const actualResponse = groups(undefined, {
|
|
type: 'ADD_GROUP',
|
|
id,
|
|
value,
|
|
active,
|
|
disabled,
|
|
});
|
|
|
|
expect(actualResponse).to.eql(expectedResponse);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('when groups exist', () => {
|
|
let state;
|
|
|
|
beforeEach(() => {
|
|
state = [
|
|
{
|
|
id: 1,
|
|
value: 'Group one',
|
|
active: true,
|
|
disabled: false,
|
|
},
|
|
{
|
|
id: 2,
|
|
value: 'Group two',
|
|
active: true,
|
|
disabled: false,
|
|
},
|
|
];
|
|
});
|
|
|
|
describe('CLEAR_CHOICES', () => {
|
|
it('restores to defaultState', () => {
|
|
const clonedState = state.slice(0);
|
|
const expectedResponse = defaultState;
|
|
const actualResponse = groups(clonedState, {
|
|
type: 'CLEAR_CHOICES',
|
|
});
|
|
|
|
expect(actualResponse).to.eql(expectedResponse);
|
|
});
|
|
});
|
|
});
|
|
});
|