mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-11-30 09:34:29 +00:00
progress
This commit is contained in:
1 parent
bf946f179a
commit
ec448b72e2
10 files changed
+1079
-449
No files matched your search
@@ -1,11 +1,12 @@
|
||||
import { describe, it } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import type { FileStructure, Selection } from 'gpx-rs';
|
||||
import type { Clipboard, FileStructure, Selection } from 'gpx-rs';
|
||||
import type { VisibilityState } from './file-visibility';
|
||||
import {
|
||||
elementId,
|
||||
hasSelectionWithin,
|
||||
isCovered,
|
||||
isInClipboard,
|
||||
isEmpty,
|
||||
isSelected,
|
||||
isSelectionHidden,
|
||||
@@ -75,6 +76,26 @@ describe('selection helpers', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('tells which nodes are in the clipboard', () => {
|
||||
const clipboard = (type: Clipboard['type'], ids: string[]): Clipboard => ({
|
||||
type,
|
||||
ids,
|
||||
cut: true,
|
||||
});
|
||||
assert.deepEqual(
|
||||
matching(empty, (_, node) => isInClipboard(undefined, node)),
|
||||
[]
|
||||
);
|
||||
const inClipboard = (c: Clipboard) =>
|
||||
Object.keys(nodes).filter((name) => isInClipboard(c, nodes[name]));
|
||||
assert.deepEqual(inClipboard(clipboard('files', ['F2'])), ['F2']);
|
||||
assert.deepEqual(inClipboard(clipboard('tracks', ['T2', 'S1'])), ['T2']);
|
||||
assert.deepEqual(inClipboard(clipboard('segments', ['S1', 'S3'])), ['S1', 'S3']);
|
||||
assert.deepEqual(inClipboard(clipboard('waypoints', ['W2'])), ['W2']);
|
||||
// not mixed up with the other kinds of elements
|
||||
assert.deepEqual(inClipboard(clipboard('files', ['T1', 'S1', 'W1'])), []);
|
||||
});
|
||||
|
||||
it('counts the selected elements', () => {
|
||||
assert.equal(selectionSize(empty), 0);
|
||||
assert.equal(selectionSize(files('F1', 'F2')), 2);
|
||||
|
||||
Reference in new issue
Block a user