Fix fill color reducer test

This commit is contained in:
adroitwhiz 2020-07-09 18:00:12 -04:00
parent f8da455005
commit a23fabd778

View file

@ -1,8 +1,9 @@
/* eslint-env jest */ /* eslint-env jest */
import fillColorReducer from '../../src/reducers/fill-color'; import fillColorReducer from '../../src/reducers/fill-style';
import {changeFillColor} from '../../src/reducers/fill-color'; import {changeFillColor} from '../../src/reducers/fill-style';
import {setSelectedItems} from '../../src/reducers/selected-items'; import {setSelectedItems} from '../../src/reducers/selected-items';
import {MIXED} from '../../src/helper/style-path'; import {MIXED} from '../../src/helper/style-path';
import GradientTypes from '../../src/lib/gradient-types';
import {mockPaperRootItem} from '../__mocks__/paperMocks'; import {mockPaperRootItem} from '../__mocks__/paperMocks';
test('initialState', () => { test('initialState', () => {
@ -16,16 +17,16 @@ test('changeFillColor', () => {
// 3 value hex code // 3 value hex code
let newFillColor = '#fff'; let newFillColor = '#fff';
expect(fillColorReducer(defaultState /* state */, changeFillColor(newFillColor) /* action */)) expect(fillColorReducer(defaultState /* state */, changeFillColor(newFillColor) /* action */).primary)
.toEqual(newFillColor); .toEqual(newFillColor);
expect(fillColorReducer('#010' /* state */, changeFillColor(newFillColor) /* action */)) expect(fillColorReducer('#010' /* state */, changeFillColor(newFillColor) /* action */).primary)
.toEqual(newFillColor); .toEqual(newFillColor);
// 6 value hex code // 6 value hex code
newFillColor = '#facade'; newFillColor = '#facade';
expect(fillColorReducer(defaultState /* state */, changeFillColor(newFillColor) /* action */)) expect(fillColorReducer(defaultState /* state */, changeFillColor(newFillColor) /* action */).primary)
.toEqual(newFillColor); .toEqual(newFillColor);
expect(fillColorReducer('#010' /* state */, changeFillColor(newFillColor) /* action */)) expect(fillColorReducer('#010' /* state */, changeFillColor(newFillColor) /* action */).primary)
.toEqual(newFillColor); .toEqual(newFillColor);
}); });
@ -35,18 +36,18 @@ test('changefillColorViaSelectedItems', () => {
const fillColor1 = 6; const fillColor1 = 6;
const fillColor2 = null; // transparent const fillColor2 = null; // transparent
let selectedItems = [mockPaperRootItem({fillColor: fillColor1})]; let selectedItems = [mockPaperRootItem({fillColor: fillColor1})];
expect(fillColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */)) expect(fillColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */).primary)
.toEqual(fillColor1); .toEqual(fillColor1);
selectedItems = [mockPaperRootItem({fillColor: fillColor2})]; selectedItems = [mockPaperRootItem({fillColor: fillColor2})];
expect(fillColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */)) expect(fillColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */).primary)
.toEqual(fillColor2); .toEqual(fillColor2);
selectedItems = [mockPaperRootItem({fillColor: fillColor1}), mockPaperRootItem({fillColor: fillColor2})]; selectedItems = [mockPaperRootItem({fillColor: fillColor1}), mockPaperRootItem({fillColor: fillColor2})];
expect(fillColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */)) expect(fillColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */).primary)
.toEqual(MIXED); .toEqual(MIXED);
}); });
test('invalidChangeFillColor', () => { test('invalidChangeFillColor', () => {
const origState = '#fff'; const origState = {primary: '#fff', secondary: null, gradientType: GradientTypes.SOLID};
expect(fillColorReducer(origState /* state */, changeFillColor() /* action */)) expect(fillColorReducer(origState /* state */, changeFillColor() /* action */))
.toBe(origState); .toBe(origState);