droboticflow/tests/frontend/slice-edit-change-summary.test.mjs

33 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import assert from "node:assert/strict";
import test from "node:test";
import { sliceEditChangeSummary } from "../../src/lib/slice-edit-conflict-list.js";
test("shared boundary changes describe both slices, separately from affected actions", () => {
const before = [
{ id: "a", name: "拿取", start: 0, end: 60 },
{ id: "b", name: "放置", start: 60, end: 100 },
];
const after = [
{ ...before[0], end: 70 },
{ ...before[1], start: 70 },
];
assert.deepEqual(sliceEditChangeSummary(before, after), [
"拿取:0.00s–60.00s → 0.00s–70.00s",
"放置:60.00s–100.00s → 70.00s–100.00s",
]);
assert.deepEqual(sliceEditChangeSummary(before, before), []);
});
test("split and merge summaries preserve removed and added slice ranges", () => {
const before = [{ id: "a", name: "原片", start: 0, end: 60 }];
const after = [
{ id: "b", name: "新片一", start: 0, end: 30 },
{ id: "c", name: "新片二", start: 30, end: 60 },
];
assert.deepEqual(sliceEditChangeSummary(before, after), [
"原片:0.00s–60.00s → 已重新划分",
"新片一:新增 0.00s–30.00s",
"新片二:新增 30.00s–60.00s",
]);
});