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