Choices/src/scripts/actions/items.test.ts

73 lines
1.6 KiB
TypeScript
Raw Normal View History

2017-10-10 16:26:38 +02:00
import { expect } from 'chai';
import * as actions from './items';
2017-10-29 19:56:24 +01:00
describe('actions/items', () => {
2017-10-10 16:26:38 +02:00
describe('addItem action', () => {
it('returns ADD_ITEM action', () => {
const value = 'test';
const label = 'test';
const id = 1;
const choiceId = 1;
const groupId = 1;
const customProperties = { test: true };
const placeholder = true;
2017-10-10 16:26:38 +02:00
const keyCode = 10;
const expectedAction: actions.AddItemAction = {
2017-10-10 16:26:38 +02:00
type: 'ADD_ITEM',
value,
label,
id,
choiceId,
groupId,
customProperties,
placeholder,
keyCode,
};
expect(
2018-05-29 20:55:33 +02:00
actions.addItem({
value,
label,
id,
choiceId,
groupId,
customProperties,
placeholder,
keyCode,
2018-05-29 20:55:33 +02:00
}),
).to.eql(expectedAction);
2017-10-10 16:26:38 +02:00
});
});
describe('removeItem action', () => {
it('returns REMOVE_ITEM action', () => {
const id = 1;
const choiceId = 1;
const expectedAction: actions.RemoveItemAction = {
2017-10-10 16:26:38 +02:00
type: 'REMOVE_ITEM',
id,
choiceId,
};
expect(actions.removeItem(id, choiceId)).to.eql(expectedAction);
});
});
describe('highlightItem action', () => {
it('returns HIGHLIGHT_ITEM action', () => {
const id = 1;
2017-10-10 16:26:38 +02:00
const highlighted = true;
const expectedAction: actions.HighlightItemAction = {
2017-10-10 16:26:38 +02:00
type: 'HIGHLIGHT_ITEM',
id,
highlighted,
};
expect(actions.highlightItem(id, highlighted)).to.eql(expectedAction);
});
});
});