forked from mm7894215/TokenTracker
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvalidate-ui-hardcode.test.js
More file actions
39 lines (35 loc) · 1.03 KB
/
Copy pathvalidate-ui-hardcode.test.js
File metadata and controls
39 lines (35 loc) · 1.03 KB
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
36
37
38
39
const assert = require("node:assert/strict");
const { test } = require("node:test");
const {
extractJsxTextTokens,
diffAgainstBaseline,
} = require("../scripts/ops/validate-ui-hardcode-lib.cjs");
test("extractJsxTextTokens includes unicode letters and digits", () => {
const tokens = extractJsxTextTokens("<div>123</div><span>中文</span><p>abc</p>");
assert.deepEqual(tokens, ["123", "中文", "abc"]);
});
test("diffAgainstBaseline flags new rawText tokens even if count unchanged", () => {
const current = {
files: {
"dashboard/src/ui/Foo.tsx": {
colors: 0,
rawText: 1,
rawTextTokens: ["Hello world"],
},
},
};
const baseline = {
files: {
"dashboard/src/ui/Foo.tsx": {
colors: 0,
rawText: 1,
rawTextTokens: ["Hello"],
},
},
};
const errors = diffAgainstBaseline(current, baseline);
assert.ok(
errors.some((line) => line.includes("rawText tokens introduced")),
`expected rawText token diff, got:\n${errors.join("\n")}`,
);
});