-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnector-text.test.ts
More file actions
35 lines (32 loc) · 1006 Bytes
/
connector-text.test.ts
File metadata and controls
35 lines (32 loc) · 1006 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
30
31
32
33
34
35
import { describe, expect, it } from "bun:test";
import {
collectNormalizedConnectors,
extractConnectorPairFromText,
} from "./connector-text";
describe("extractConnectorPairFromText", () => {
it("parses USB-C to USB-C titles without regex backtracking", () => {
expect(extractConnectorPairFromText("USB-C to USB-C Cable")).toEqual({
from: "USB-C",
matchedText: "usb c to usb c",
to: "USB-C",
});
});
it("normalizes Thunderbolt connectors to USB-C physical endpoints", () => {
expect(
extractConnectorPairFromText("Thunderbolt 5 to USB-C Pro Cable")
).toEqual({
from: "USB-C",
matchedText: "thunderbolt 5 to usb c",
to: "USB-C",
});
});
});
describe("collectNormalizedConnectors", () => {
it("deduplicates normalized connectors from free text", () => {
expect(
collectNormalizedConnectors(
"Works with USB-C, Thunderbolt 4, and Lightning accessories."
)
).toEqual(["USB-C", "Lightning"]);
});
});