UNPKG

lucid-ui

Version:

A UI component library from AppNexus.

35 lines 1.31 kB
import _isEqual from "lodash/isEqual"; import assert from 'assert'; import { onSelect, onSearch } from './SearchableSelect.reducers'; describe('SearchableSelect reducers', function () { describe('onSelect', function () { it('should set selectedIndex=[newIndex] and update DropMenu state', function () { var initialState = {}; var newIndex = 3; var nextState = onSelect(initialState, newIndex); var selectedIndex = nextState.selectedIndex, DropMenu = nextState.DropMenu; assert(_isEqual(DropMenu, { isExpanded: false, selectedIndices: [3] })); assert(_isEqual(selectedIndex, newIndex)); }); }); describe('onSearch', function () { it('should set searchText=[inputText], selectedIndex=null, and update DropMenu state', function () { var initialState = {}; var inputText = 'search'; var firstVisibleIndex = 41; var nextState = onSearch(initialState, inputText, firstVisibleIndex); var searchText = nextState.searchText, selectedIndex = nextState.selectedIndex, DropMenu = nextState.DropMenu; assert.equal(searchText, inputText); assert.equal(selectedIndex, null); assert(_isEqual(DropMenu, { focusedIndex: firstVisibleIndex })); }); }); });