16 lines
563 B
TypeScript
16 lines
563 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { moveArrayItem } from "../lib/array";
|
|
|
|
describe("moveArrayItem", () => {
|
|
it("moves an item to a new position", () => {
|
|
expect(moveArrayItem(["a", "b", "c"], 0, 2)).toEqual(["b", "c", "a"]);
|
|
});
|
|
|
|
it("returns the original order when the move is invalid", () => {
|
|
expect(moveArrayItem(["a", "b", "c"], -1, 2)).toEqual(["a", "b", "c"]);
|
|
expect(moveArrayItem(["a", "b", "c"], 1, 1)).toEqual(["a", "b", "c"]);
|
|
expect(moveArrayItem(["a", "b", "c"], 1, 5)).toEqual(["a", "b", "c"]);
|
|
});
|
|
});
|