mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-06-14 14:11:57 -04:00
Offset the pasted item from the original when on the same costume
This commit is contained in:
parent
cc920e8969
commit
a5a60b0884
5 changed files with 97 additions and 18 deletions
test/unit
|
@ -1,11 +1,12 @@
|
|||
/* eslint-env jest */
|
||||
import clipboardReducer from '../../src/reducers/clipboard';
|
||||
import {setClipboardItems} from '../../src/reducers/clipboard';
|
||||
import {clearPasteOffset, incrementPasteOffset, setClipboardItems} from '../../src/reducers/clipboard';
|
||||
|
||||
test('initialState', () => {
|
||||
let defaultState;
|
||||
|
||||
expect(clipboardReducer(defaultState /* state */, {type: 'anything'} /* action */)).toBeDefined();
|
||||
expect(clipboardReducer(defaultState /* state */, {type: 'anything'} /* action */).items).toBeDefined();
|
||||
expect(clipboardReducer(defaultState /* state */, {type: 'anything'} /* action */).pasteOffset).toBeDefined();
|
||||
});
|
||||
|
||||
test('setClipboardItems', () => {
|
||||
|
@ -13,14 +14,45 @@ test('setClipboardItems', () => {
|
|||
|
||||
const newSelected1 = ['selected1', 'selected2'];
|
||||
const newSelected2 = ['selected1', 'selected3'];
|
||||
expect(clipboardReducer(defaultState /* state */, setClipboardItems(newSelected1) /* action */))
|
||||
expect(clipboardReducer(defaultState /* state */, setClipboardItems(newSelected1) /* action */).items)
|
||||
.toEqual(newSelected1);
|
||||
expect(clipboardReducer(newSelected1, setClipboardItems(newSelected2) /* action */))
|
||||
expect(clipboardReducer(defaultState /* state */, setClipboardItems(newSelected1) /* action */).pasteOffset)
|
||||
.toEqual(1);
|
||||
expect(clipboardReducer(newSelected1, setClipboardItems(newSelected2) /* action */).items)
|
||||
.toEqual(newSelected2);
|
||||
expect(clipboardReducer(defaultState /* state */, setClipboardItems(newSelected1) /* action */).pasteOffset)
|
||||
.toEqual(1);
|
||||
});
|
||||
|
||||
test('incrementPasteOffset', () => {
|
||||
const origState = {
|
||||
items: ['selected1', 'selected2'],
|
||||
pasteOffset: 1
|
||||
};
|
||||
|
||||
expect(clipboardReducer(origState /* state */, incrementPasteOffset() /* action */).pasteOffset)
|
||||
.toEqual(2);
|
||||
expect(clipboardReducer(origState, incrementPasteOffset() /* action */).items)
|
||||
.toEqual(origState.items);
|
||||
});
|
||||
|
||||
test('clearPasteOffset', () => {
|
||||
const origState = {
|
||||
items: ['selected1', 'selected2'],
|
||||
pasteOffset: 1
|
||||
};
|
||||
|
||||
expect(clipboardReducer(origState /* state */, clearPasteOffset() /* action */).pasteOffset)
|
||||
.toEqual(0);
|
||||
expect(clipboardReducer(origState, clearPasteOffset() /* action */).items)
|
||||
.toEqual(origState.items);
|
||||
});
|
||||
|
||||
test('invalidSetClipboardItems', () => {
|
||||
const origState = ['selected1', 'selected2'];
|
||||
const origState = {
|
||||
items: ['selected1', 'selected2'],
|
||||
pasteOffset: 1
|
||||
};
|
||||
const nothingSelected = [];
|
||||
|
||||
expect(clipboardReducer(origState /* state */, setClipboardItems() /* action */))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue