lucid-ui
Version:
A UI component library from AppNexus.
43 lines • 1.14 kB
JavaScript
import { onSelect, onSearch, onRemoveAll } from './SearchableMultiSelect.reducers';
describe('SearchableMultiSelect reducers', function () {
describe('onSelect', function () {
it('should add an index', function () {
var state = {
selectedIndices: [2, 3]
};
var expected = {
selectedIndices: [2, 3, 1]
};
expect(onSelect(state, 1)).toEqual(expected);
});
it('should remove an index', function () {
var state = {
selectedIndices: [1, 2, 3]
};
var expected = {
selectedIndices: [1, 2]
};
expect(onSelect(state, 3)).toEqual(expected);
});
});
describe('onSearch', function () {
it('should correctly set state', function () {
var expected = {
searchText: 'wat',
DropMenu: {
focusedIndex: 0
}
};
expect(onSearch({}, 'wat', 0)).toEqual(expected);
});
});
describe('onRemoveAll', function () {
var state = {
selectedIndices: [1, 2, 3, 4]
};
var expected = {
selectedIndices: []
};
expect(onRemoveAll(state)).toEqual(expected);
});
});