2017-09-14 11:56:12 -04:00
|
|
|
/* eslint-env jest */
|
2021-02-09 12:14:00 -05:00
|
|
|
import reducer, {clearHoveredItem, setHoveredItem} from '../../src/reducers/hover';
|
2017-09-14 11:56:12 -04:00
|
|
|
|
|
|
|
test('initialState', () => {
|
|
|
|
let defaultState;
|
|
|
|
expect(reducer(defaultState /* state */, {type: 'anything'} /* action */)).toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('setHoveredItem', () => {
|
|
|
|
let defaultState;
|
2017-09-22 13:48:18 -04:00
|
|
|
const item1 = 1;
|
|
|
|
const item2 = 2;
|
2017-09-14 11:56:12 -04:00
|
|
|
expect(reducer(defaultState /* state */, setHoveredItem(item1) /* action */)).toBe(item1);
|
|
|
|
expect(reducer(item1 /* state */, setHoveredItem(item2) /* action */)).toBe(item2);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('clearHoveredItem', () => {
|
|
|
|
let defaultState;
|
2017-09-22 13:48:18 -04:00
|
|
|
const item = 1;
|
2017-09-14 11:56:12 -04:00
|
|
|
expect(reducer(defaultState /* state */, clearHoveredItem() /* action */)).toBeNull();
|
|
|
|
expect(reducer(item /* state */, clearHoveredItem() /* action */)).toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('invalidSetHoveredItem', () => {
|
|
|
|
let defaultState;
|
2017-09-22 13:48:18 -04:00
|
|
|
const item = 1;
|
2017-09-14 11:56:12 -04:00
|
|
|
const nonItem = {random: 'object'};
|
|
|
|
let undef;
|
|
|
|
expect(reducer(defaultState /* state */, setHoveredItem(nonItem) /* action */)).toBeNull();
|
|
|
|
expect(reducer(item /* state */, setHoveredItem(nonItem) /* action */))
|
|
|
|
.toBe(item);
|
|
|
|
expect(reducer(item /* state */, setHoveredItem(undef) /* action */))
|
|
|
|
.toBe(item);
|
|
|
|
});
|