2017-07-27 22:58:31 -04:00
|
|
|
/* eslint-env jest */
|
2021-02-09 12:14:00 -05:00
|
|
|
import brushReducer, {changeBrushSize} from '../../src/reducers/brush-mode';
|
|
|
|
import eraserReducer, {changeBrushSize as changeEraserSize} from '../../src/reducers/eraser-mode';
|
2017-07-27 22:58:31 -04:00
|
|
|
|
|
|
|
test('initialState', () => {
|
|
|
|
let defaultState;
|
|
|
|
|
|
|
|
expect(brushReducer(defaultState /* state */, {type: 'anything'} /* action */)).toBeDefined();
|
|
|
|
expect(brushReducer(defaultState /* state */, {type: 'anything'} /* action */).brushSize).toBeGreaterThan(0);
|
|
|
|
|
|
|
|
expect(eraserReducer(defaultState /* state */, {type: 'anything'} /* action */)).toBeTruthy();
|
|
|
|
expect(eraserReducer(defaultState /* state */, {type: 'anything'} /* action */).brushSize).toBeGreaterThan(0);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('changeBrushSize', () => {
|
|
|
|
let defaultState;
|
2021-03-08 14:44:30 -05:00
|
|
|
|
2017-07-27 22:58:31 -04:00
|
|
|
const newBrushSize = 8078;
|
|
|
|
|
2017-08-16 15:34:33 -04:00
|
|
|
expect(brushReducer(defaultState /* state */, changeBrushSize(newBrushSize) /* action */))
|
2017-07-27 22:58:31 -04:00
|
|
|
.toEqual({brushSize: newBrushSize});
|
2017-08-16 15:34:33 -04:00
|
|
|
expect(brushReducer(1 /* state */, changeBrushSize(newBrushSize) /* action */))
|
2017-07-27 22:58:31 -04:00
|
|
|
.toEqual({brushSize: newBrushSize});
|
|
|
|
|
2017-08-16 15:34:33 -04:00
|
|
|
expect(eraserReducer(defaultState /* state */, changeEraserSize(newBrushSize) /* action */))
|
2017-07-27 22:58:31 -04:00
|
|
|
.toEqual({brushSize: newBrushSize});
|
2017-08-16 15:34:33 -04:00
|
|
|
expect(eraserReducer(1 /* state */, changeEraserSize(newBrushSize) /* action */))
|
2017-07-27 22:58:31 -04:00
|
|
|
.toEqual({brushSize: newBrushSize});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('invalidChangeBrushSize', () => {
|
|
|
|
const origState = {brushSize: 1};
|
|
|
|
|
2017-08-16 15:34:33 -04:00
|
|
|
expect(brushReducer(origState /* state */, changeBrushSize('invalid argument') /* action */))
|
2017-07-27 22:58:31 -04:00
|
|
|
.toBe(origState);
|
2017-08-16 15:34:33 -04:00
|
|
|
expect(brushReducer(origState /* state */, changeBrushSize() /* action */))
|
2017-07-27 22:58:31 -04:00
|
|
|
.toBe(origState);
|
|
|
|
|
2017-08-16 15:34:33 -04:00
|
|
|
expect(eraserReducer(origState /* state */, changeEraserSize('invalid argument') /* action */))
|
2017-07-27 22:58:31 -04:00
|
|
|
.toBe(origState);
|
2017-08-16 15:34:33 -04:00
|
|
|
expect(eraserReducer(origState /* state */, changeEraserSize() /* action */))
|
2017-07-27 22:58:31 -04:00
|
|
|
.toBe(origState);
|
|
|
|
});
|