mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Add support for forward (#100)
This commit is contained in:
parent
e9484080e7
commit
6b8d2970ac
2 changed files with 148 additions and 2 deletions
|
@ -1,6 +1,11 @@
|
|||
import { moveOneLeft, moveAllLeft } from "./zindex";
|
||||
import { moveOneLeft, moveOneRight, moveAllLeft, moveAllRight } from "./zindex";
|
||||
|
||||
function expectMove(fn, elems, indices, equal) {
|
||||
function expectMove<T>(
|
||||
fn: (elements: T[], indicesToMove: number[]) => void,
|
||||
elems: T[],
|
||||
indices: number[],
|
||||
equal: T[]
|
||||
) {
|
||||
fn(elems, indices);
|
||||
expect(elems).toEqual(equal);
|
||||
}
|
||||
|
@ -17,6 +22,18 @@ it("should moveOneLeft", () => {
|
|||
expectMove(moveOneLeft, ["a", "b", "c", "d"], [1, 3], ["b", "a", "d", "c"]);
|
||||
});
|
||||
|
||||
it("should moveOneRight", () => {
|
||||
expectMove(moveOneRight, ["a", "b", "c", "d"], [1, 2], ["a", "d", "b", "c"]);
|
||||
expectMove(moveOneRight, ["a", "b", "c", "d"], [3], ["a", "b", "c", "d"]);
|
||||
expectMove(
|
||||
moveOneRight,
|
||||
["a", "b", "c", "d"],
|
||||
[0, 1, 2, 3],
|
||||
["a", "b", "c", "d"]
|
||||
);
|
||||
expectMove(moveOneRight, ["a", "b", "c", "d"], [0, 2], ["b", "a", "d", "c"]);
|
||||
});
|
||||
|
||||
it("should moveAllLeft", () => {
|
||||
expectMove(
|
||||
moveAllLeft,
|
||||
|
@ -49,3 +66,36 @@ it("should moveAllLeft", () => {
|
|||
["e", "f", "g", "a", "b", "c", "d"]
|
||||
);
|
||||
});
|
||||
|
||||
it("should moveAllRight", () => {
|
||||
expectMove(
|
||||
moveAllRight,
|
||||
["a", "b", "c", "d", "e", "f", "g"],
|
||||
[2, 5],
|
||||
["a", "b", "d", "e", "g", "c", "f"]
|
||||
);
|
||||
expectMove(
|
||||
moveAllRight,
|
||||
["a", "b", "c", "d", "e", "f", "g"],
|
||||
[5],
|
||||
["a", "b", "c", "d", "e", "g", "f"]
|
||||
);
|
||||
expectMove(
|
||||
moveAllRight,
|
||||
["a", "b", "c", "d", "e", "f", "g"],
|
||||
[0, 1, 2, 3, 4, 5, 6],
|
||||
["a", "b", "c", "d", "e", "f", "g"]
|
||||
);
|
||||
expectMove(
|
||||
moveAllRight,
|
||||
["a", "b", "c", "d", "e", "f", "g"],
|
||||
[0, 1, 2],
|
||||
["d", "e", "f", "g", "a", "b", "c"]
|
||||
);
|
||||
expectMove(
|
||||
moveAllRight,
|
||||
["a", "b", "c", "d", "e", "f", "g"],
|
||||
[4, 5, 6],
|
||||
["a", "b", "c", "d", "e", "f", "g"]
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue