scratch-paint/test/unit/modes-reducer.test.js
2021-02-09 12:20:26 -05:00

23 lines
918 B
JavaScript

/* eslint-env jest */
import Modes from '../../src/lib/modes';
import reducer, {changeMode} from '../../src/reducers/modes';
test('initialState', () => {
let defaultState;
expect(reducer(defaultState /* state */, {type: 'anything'} /* action */) in Modes).toBeTruthy();
});
test('changeMode', () => {
let defaultState;
expect(reducer(defaultState /* state */, changeMode(Modes.ERASER) /* action */)).toBe(Modes.ERASER);
expect(reducer(Modes.ERASER /* state */, changeMode(Modes.ERASER) /* action */))
.toBe(Modes.ERASER);
expect(reducer(Modes.BRUSH /* state */, changeMode(Modes.ERASER) /* action */))
.toBe(Modes.ERASER);
});
test('invalidChangeMode', () => {
expect(reducer(Modes.BRUSH /* state */, changeMode('non-existant mode') /* action */))
.toBe(Modes.BRUSH);
expect(reducer(Modes.BRUSH /* state */, changeMode() /* action */)).toBe(Modes.BRUSH);
});