forked from longtao.wu/droboticflow
25 lines
1.2 KiB
JavaScript
25 lines
1.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { adjacentAnnotation } from "../../src/lib/annotation-list-navigation.js";
|
|
|
|
const actions = [
|
|
{ id: "first", start: 10, end: 20 },
|
|
{ id: "second", start: 30, end: 40 },
|
|
];
|
|
|
|
test("action navigation keeps its selected identity at shared boundaries and stops at either end", () => {
|
|
assert.equal(adjacentAnnotation(actions, "first", 20, 1), actions[1]);
|
|
assert.equal(adjacentAnnotation(actions, "second", 40, -1), actions[0]);
|
|
assert.equal(adjacentAnnotation(actions, "first", 20, -1), null);
|
|
assert.equal(adjacentAnnotation(actions, "second", 40, 1), null);
|
|
});
|
|
|
|
test("without a selection action navigation starts near the playhead and handles gaps and empty slices", () => {
|
|
assert.equal(adjacentAnnotation(actions, undefined, 15, 1), actions[0]);
|
|
assert.equal(adjacentAnnotation(actions, undefined, 25, 1), actions[1]);
|
|
assert.equal(adjacentAnnotation(actions, undefined, 25, -1), actions[0]);
|
|
assert.equal(adjacentAnnotation(actions, undefined, 50, 1), actions[1]);
|
|
assert.equal(adjacentAnnotation(actions, undefined, 0, -1), actions[0]);
|
|
assert.equal(adjacentAnnotation([], undefined, 0, 1), null);
|
|
});
|