2018-04-05 18:06:37 -04:00
|
|
|
/* eslint-env jest */
|
|
|
|
import Formats from '../../src/lib/format';
|
2021-02-09 12:14:00 -05:00
|
|
|
import reducer, {changeFormat} from '../../src/reducers/format';
|
2018-04-09 20:10:53 -04:00
|
|
|
import {undo, redo} from '../../src/reducers/undo';
|
2018-04-05 18:06:37 -04:00
|
|
|
|
|
|
|
test('initialState', () => {
|
|
|
|
let defaultState;
|
2018-04-26 18:45:50 -04:00
|
|
|
expect(reducer(defaultState /* state */, {type: 'anything'} /* action */)).toBeNull();
|
2018-04-05 18:06:37 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
test('changeFormat', () => {
|
|
|
|
let defaultState;
|
|
|
|
expect(reducer(defaultState /* state */, changeFormat(Formats.BITMAP) /* action */)).toBe(Formats.BITMAP);
|
|
|
|
expect(reducer(Formats.BITMAP /* state */, changeFormat(Formats.BITMAP) /* action */))
|
|
|
|
.toBe(Formats.BITMAP);
|
|
|
|
expect(reducer(Formats.BITMAP /* state */, changeFormat(Formats.VECTOR) /* action */))
|
|
|
|
.toBe(Formats.VECTOR);
|
|
|
|
});
|
|
|
|
|
2018-04-09 20:10:53 -04:00
|
|
|
test('undoRedoChangeFormat', () => {
|
|
|
|
let defaultState;
|
|
|
|
let reduxState = reducer(defaultState /* state */, changeFormat(Formats.BITMAP) /* action */);
|
|
|
|
expect(reduxState).toBe(Formats.BITMAP);
|
2018-04-11 14:38:41 -04:00
|
|
|
reduxState = reducer(reduxState /* state */, undo(Formats.BITMAP_SKIP_CONVERT) /* action */);
|
|
|
|
expect(reduxState).toBe(Formats.BITMAP_SKIP_CONVERT);
|
|
|
|
reduxState = reducer(reduxState /* state */, redo(Formats.VECTOR_SKIP_CONVERT) /* action */);
|
|
|
|
expect(reduxState).toBe(Formats.VECTOR_SKIP_CONVERT);
|
2018-04-09 20:10:53 -04:00
|
|
|
});
|
|
|
|
|
2018-04-05 18:06:37 -04:00
|
|
|
test('invalidChangeMode', () => {
|
|
|
|
expect(reducer(Formats.BITMAP /* state */, changeFormat('non-existant mode') /* action */))
|
|
|
|
.toBe(Formats.BITMAP);
|
|
|
|
expect(reducer(Formats.BITMAP /* state */, changeFormat() /* action */)).toBe(Formats.BITMAP);
|
|
|
|
});
|