-
Notifications
You must be signed in to change notification settings - Fork 137
Expand file tree
/
Copy pathexecution-point-utils.test.ts
More file actions
29 lines (25 loc) · 1021 Bytes
/
execution-point-utils.test.ts
File metadata and controls
29 lines (25 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { comparePoints, pointEquals, pointPrecedes } from "./execution-point-utils";
describe("execution-point-utils", () => {
describe("pointEquals", () => {
it("returns true for identical string points", () => {
expect(pointEquals("100", "100")).toBe(true);
});
it("returns false for different points", () => {
expect(pointEquals("100", "101")).toBe(false);
});
});
describe("pointPrecedes / comparePoints", () => {
it("orders by length first (shorter numeric string is smaller)", () => {
expect(pointPrecedes("9", "10")).toBe(true);
expect(pointPrecedes("10", "9")).toBe(false);
expect(comparePoints("9", "10")).toBe(-1);
expect(comparePoints("10", "9")).toBe(1);
});
it("uses lexicographic order when lengths match", () => {
expect(comparePoints("12", "34")).toBe(-1);
expect(comparePoints("34", "12")).toBe(1);
expect(comparePoints("99", "99")).toBe(0);
expect(pointPrecedes("12", "34")).toBe(true);
});
});
});