-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sorter_test.ts
24 lines (21 loc) · 984 Bytes
/
sorter_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { assertType, type IsExact } from "@std/testing/types";
import { DenopsStub } from "@denops/test/stub";
import type { DetailUnit } from "./item.ts";
import type { Sorter, SortParams } from "./sorter.ts";
Deno.test("Sorter", async (t) => {
const denops = new DenopsStub();
await t.step("without type constraint is equal to UnitDetail", () => {
assertType<IsExact<Sorter, Sorter<DetailUnit>>>(true);
});
await t.step("sort follows the type constraint", () => {
const sorter: Sorter<{ a: string }> = { sort: () => {} };
sorter.sort(denops, {} as SortParams<{ a: string }>, {});
sorter.sort(denops, {} as SortParams<{ a: string; b: string }>, {});
// @ts-expect-error: 'a' is missing
sorter.sort(denops, {} as SortParams<{ b: string }>, {});
// @ts-expect-error: 'a' is missing
sorter.sort(denops, {} as SortParams<Detail>, {});
// @ts-expect-error: 'a' is missing
sorter.sort(denops, {} as SortParams<DetailUnit>, {});
});
});