diff --git a/test/unit/components/eraser-mode.test.jsx b/test/unit/components/eraser-mode.test.jsx new file mode 100644 index 00000000..4772581c --- /dev/null +++ b/test/unit/components/eraser-mode.test.jsx @@ -0,0 +1,15 @@ +/* eslint-env jest */ +import React from 'react'; // eslint-disable-line no-unused-vars +import {shallow} from 'enzyme'; +import EraserModeComponent from '../../../src/components/eraser-mode.jsx'; // eslint-disable-line no-unused-vars + +describe('EraserModeComponent', () => { + test('triggers callback when clicked', () => { + const onClick = jest.fn(); + const componentShallowWrapper = shallow( + + ); + componentShallowWrapper.simulate('click'); + expect(onClick).toHaveBeenCalled(); + }); +}); diff --git a/test/unit/components/line-mode.test.jsx b/test/unit/components/line-mode.test.jsx new file mode 100644 index 00000000..7be2ff14 --- /dev/null +++ b/test/unit/components/line-mode.test.jsx @@ -0,0 +1,15 @@ +/* eslint-env jest */ +import React from 'react'; // eslint-disable-line no-unused-vars +import {shallow} from 'enzyme'; +import LineModeComponent from '../../../src/components/line-mode.jsx'; // eslint-disable-line no-unused-vars + +describe('LineModeComponent', () => { + test('triggers callback when clicked', () => { + const onClick = jest.fn(); + const componentShallowWrapper = shallow( + + ); + componentShallowWrapper.simulate('click'); + expect(onClick).toHaveBeenCalled(); + }); +}); diff --git a/test/unit/line-mode-reducer.test.js b/test/unit/line-mode-reducer.test.js new file mode 100644 index 00000000..cd24cb99 --- /dev/null +++ b/test/unit/line-mode-reducer.test.js @@ -0,0 +1,31 @@ +/* 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); +});