mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-23 05:52:42 -05:00
31 lines
1.2 KiB
JavaScript
31 lines
1.2 KiB
JavaScript
/* 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);
|
|
});
|