Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

composerSelection.test.ts

27 lines957 Bytes

1import { describe, expect, it } from "vite-plus/test";
2​
3import { didComposerSelectionChangeVisibly } from "./composerSelection";
4​
5describe("didComposerSelectionChangeVisibly", () => {
6 it("ignores selection-neutral editor updates", () => {
7 expect(didComposerSelectionChangeVisibly({ start: 3, end: 3 }, null)).toBe(false);
8 expect(didComposerSelectionChangeVisibly({ start: 3, end: 3 }, { start: 3, end: 3 })).toBe(
9 false,
10 );
11 });
12​
13 it("detects entering and extending a visible range selection", () => {
14 expect(didComposerSelectionChangeVisibly({ start: 3, end: 3 }, { start: 0, end: 3 })).toBe(
15 true,
16 );
17 expect(didComposerSelectionChangeVisibly({ start: 1, end: 3 }, { start: 0, end: 3 })).toBe(
18 true,
19 );
20 });
21​
22 it("does not repeatedly report the same visible selection", () => {
23 expect(didComposerSelectionChangeVisibly({ start: 0, end: 3 }, { start: 0, end: 3 })).toBe(
24 false,
25 );
26 });
27});