mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 13:32:28 -05:00
Fix fill color reducer test
This commit is contained in:
parent
f8da455005
commit
a23fabd778
1 changed files with 11 additions and 10 deletions
|
@ -1,8 +1,9 @@
|
|||
/* eslint-env jest */
|
||||
import fillColorReducer from '../../src/reducers/fill-color';
|
||||
import {changeFillColor} from '../../src/reducers/fill-color';
|
||||
import fillColorReducer from '../../src/reducers/fill-style';
|
||||
import {changeFillColor} from '../../src/reducers/fill-style';
|
||||
import {setSelectedItems} from '../../src/reducers/selected-items';
|
||||
import {MIXED} from '../../src/helper/style-path';
|
||||
import GradientTypes from '../../src/lib/gradient-types';
|
||||
import {mockPaperRootItem} from '../__mocks__/paperMocks';
|
||||
|
||||
test('initialState', () => {
|
||||
|
@ -16,16 +17,16 @@ test('changeFillColor', () => {
|
|||
|
||||
// 3 value hex code
|
||||
let newFillColor = '#fff';
|
||||
expect(fillColorReducer(defaultState /* state */, changeFillColor(newFillColor) /* action */))
|
||||
expect(fillColorReducer(defaultState /* state */, changeFillColor(newFillColor) /* action */).primary)
|
||||
.toEqual(newFillColor);
|
||||
expect(fillColorReducer('#010' /* state */, changeFillColor(newFillColor) /* action */))
|
||||
expect(fillColorReducer('#010' /* state */, changeFillColor(newFillColor) /* action */).primary)
|
||||
.toEqual(newFillColor);
|
||||
|
||||
// 6 value hex code
|
||||
newFillColor = '#facade';
|
||||
expect(fillColorReducer(defaultState /* state */, changeFillColor(newFillColor) /* action */))
|
||||
expect(fillColorReducer(defaultState /* state */, changeFillColor(newFillColor) /* action */).primary)
|
||||
.toEqual(newFillColor);
|
||||
expect(fillColorReducer('#010' /* state */, changeFillColor(newFillColor) /* action */))
|
||||
expect(fillColorReducer('#010' /* state */, changeFillColor(newFillColor) /* action */).primary)
|
||||
.toEqual(newFillColor);
|
||||
});
|
||||
|
||||
|
@ -35,18 +36,18 @@ test('changefillColorViaSelectedItems', () => {
|
|||
const fillColor1 = 6;
|
||||
const fillColor2 = null; // transparent
|
||||
let selectedItems = [mockPaperRootItem({fillColor: fillColor1})];
|
||||
expect(fillColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */))
|
||||
expect(fillColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */).primary)
|
||||
.toEqual(fillColor1);
|
||||
selectedItems = [mockPaperRootItem({fillColor: fillColor2})];
|
||||
expect(fillColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */))
|
||||
expect(fillColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */).primary)
|
||||
.toEqual(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);
|
||||
});
|
||||
|
||||
test('invalidChangeFillColor', () => {
|
||||
const origState = '#fff';
|
||||
const origState = {primary: '#fff', secondary: null, gradientType: GradientTypes.SOLID};
|
||||
|
||||
expect(fillColorReducer(origState /* state */, changeFillColor() /* action */))
|
||||
.toBe(origState);
|
||||
|
|
Loading…
Reference in a new issue