mirror of
https://github.com/Choices-js/Choices.git
synced 2026-03-15 15:15:46 +01:00
34 lines
1,000 B
TypeScript
34 lines
1,000 B
TypeScript
import { expect } from 'chai';
|
|
import groups from '../../../src/scripts/reducers/groups';
|
|
import { cloneObject } from '../../../src/scripts/lib/utils';
|
|
import { GroupFull } from '../../../src/scripts/interfaces/group-full';
|
|
import { ActionType } from '../../../src';
|
|
import { StateUpdate } from '../../../src/scripts/interfaces/store';
|
|
|
|
describe('reducers/groups', () => {
|
|
describe('when groups do not exist', () => {
|
|
describe('ADD_GROUP', () => {
|
|
it('adds group', () => {
|
|
const group: GroupFull = {
|
|
active: true,
|
|
disabled: false,
|
|
id: 1,
|
|
label: 'Group one',
|
|
choices: [],
|
|
};
|
|
|
|
const expectedResponse: StateUpdate<GroupFull[]> = {
|
|
update: true,
|
|
state: [group],
|
|
};
|
|
|
|
const actualResponse = groups([], {
|
|
type: ActionType.ADD_GROUP,
|
|
group: cloneObject(group),
|
|
});
|
|
|
|
expect(actualResponse).to.deep.equal(expectedResponse);
|
|
});
|
|
});
|
|
});
|
|
});
|