scratch-paint/test/unit/line-mode-reducer.test.js

32 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-08-25 10:45:22 -04:00
/* eslint-env jest */
import lineReducer from '../../src/reducers/line-mode';
import {changeLineWidth} from '../../src/reducers/line-mode';
test('initialState', () => {
let defaultState;
expect(lineReducer(defaultState /* state */, {type: 'anything'} /* action */)).toBeDefined();
expect(lineReducer(defaultState /* state */, {type: 'anything'} /* action */).lineWidth).toBeGreaterThan(0);
});
test('changeLineWidth', () => {
let defaultState;
const newLineWidth = 8078;
expect(lineReducer(defaultState /* state */, changeLineWidth(newLineWidth) /* action */))
.toEqual({lineWidth: newLineWidth});
expect(lineReducer(2 /* state */, changeLineWidth(newLineWidth) /* action */))
.toEqual({lineWidth: newLineWidth});
expect(lineReducer(2 /* state */, changeLineWidth(-1) /* action */))
.toEqual({lineWidth: 1});
});
test('invalidChangeLineWidth', () => {
const origState = {lineWidth: 2};
expect(lineReducer(origState /* state */, changeLineWidth('invalid argument') /* action */))
.toBe(origState);
expect(lineReducer(origState /* state */, changeLineWidth() /* action */))
.toBe(origState);
});