mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-06-17 00:30:46 -04:00
Make stroke width 0 when transparent (#695)
This commit is contained in:
parent
655d3d5c31
commit
c6fb28a69c
7 changed files with 87 additions and 48 deletions
|
@ -34,17 +34,29 @@ test('changeStrokeColorViaSelectedItems', () => {
|
|||
|
||||
const strokeColor1 = 6;
|
||||
const strokeColor2 = null; // transparent
|
||||
let selectedItems = [mockPaperRootItem({strokeColor: strokeColor1})];
|
||||
let selectedItems = [mockPaperRootItem({strokeColor: strokeColor1, strokeWidth: 1})];
|
||||
expect(strokeColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */))
|
||||
.toEqual(strokeColor1);
|
||||
selectedItems = [mockPaperRootItem({strokeColor: strokeColor2})];
|
||||
selectedItems = [mockPaperRootItem({strokeColor: strokeColor2, strokeWidth: 1})];
|
||||
expect(strokeColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */))
|
||||
.toEqual(strokeColor2);
|
||||
selectedItems = [mockPaperRootItem({strokeColor: strokeColor1}), mockPaperRootItem({strokeColor: strokeColor2})];
|
||||
selectedItems = [mockPaperRootItem({strokeColor: strokeColor1, strokeWidth: 1}),
|
||||
mockPaperRootItem({strokeColor: strokeColor2, strokeWidth: 1})];
|
||||
expect(strokeColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */))
|
||||
.toEqual(MIXED);
|
||||
});
|
||||
|
||||
test('showNoStrokeColorIfNoStrokeWidth', () => {
|
||||
let defaultState;
|
||||
|
||||
let selectedItems = [mockPaperRootItem({strokeColor: '#fff', strokeWidth: null})];
|
||||
expect(strokeColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */))
|
||||
.toEqual(null);
|
||||
selectedItems = [mockPaperRootItem({strokeColor: '#fff', strokeWidth: 0})];
|
||||
expect(strokeColorReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */))
|
||||
.toEqual(null);
|
||||
});
|
||||
|
||||
test('invalidChangeStrokeColor', () => {
|
||||
const origState = '#fff';
|
||||
|
||||
|
|
|
@ -30,17 +30,26 @@ test('changeStrokeWidthViaSelectedItems', () => {
|
|||
|
||||
const strokeWidth1 = 6;
|
||||
let strokeWidth2; // no outline
|
||||
let selectedItems = [mockPaperRootItem({strokeWidth: strokeWidth1})];
|
||||
let selectedItems = [mockPaperRootItem({strokeColor: '#000', strokeWidth: strokeWidth1})];
|
||||
expect(strokeWidthReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */))
|
||||
.toEqual(strokeWidth1);
|
||||
selectedItems = [mockPaperRootItem({strokeWidth: strokeWidth2})];
|
||||
selectedItems = [mockPaperRootItem({strokeColor: '#000', strokeWidth: strokeWidth2})];
|
||||
expect(strokeWidthReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */))
|
||||
.toEqual(0); // Convert no outline to stroke width 0
|
||||
selectedItems = [mockPaperRootItem({strokeWidth: strokeWidth1}), mockPaperRootItem({strokeWidth: strokeWidth2})];
|
||||
selectedItems = [mockPaperRootItem({strokeColor: '#000', strokeWidth: strokeWidth1}),
|
||||
mockPaperRootItem({strokeColor: '#000', strokeWidth: strokeWidth2})];
|
||||
expect(strokeWidthReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */))
|
||||
.toEqual(null); // null indicates mixed for stroke width
|
||||
});
|
||||
|
||||
test('showNoStrokeWidthIfNoStrokeColor', () => {
|
||||
let defaultState;
|
||||
|
||||
const selectedItems = [mockPaperRootItem({strokeColor: null, strokeWidth: 10})];
|
||||
expect(strokeWidthReducer(defaultState /* state */, setSelectedItems(selectedItems) /* action */))
|
||||
.toEqual(0);
|
||||
});
|
||||
|
||||
test('invalidChangestrokeWidth', () => {
|
||||
const origState = {strokeWidth: 1};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue