-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.ts
More file actions
94 lines (79 loc) · 2.72 KB
/
index.test.ts
File metadata and controls
94 lines (79 loc) · 2.72 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* SPDX-FileCopyrightText: 2025-present Kriasoft
* SPDX-License-Identifier: MIT
*/
import { test, describe } from "node:test";
import assert from "node:assert";
import type { Theme } from "codenames/all";
describe("PR Codename GitHub Action", () => {
test("should generate codename from number 42", async () => {
// Simple integration test - import the index and verify basic functionality
const { codename, themes } = await import("codenames/all");
// Test that the codename function works with valid themes
const result = codename(42, "animals-20");
assert.strictEqual(typeof result, "string");
assert.ok(result.length > 0);
// Verify themes array is properly exported
assert.ok(Array.isArray(themes));
assert.ok(themes.includes("animals-20"));
assert.ok(themes.includes("cities-30"));
});
test("should have all expected theme categories", async () => {
const { themes } = await import("codenames/all");
const categories = [
"adjectives",
"animals",
"cities",
"clothing",
"colors",
"countries",
"elements",
"emotions",
"food",
"gems",
"nature",
"snacks",
];
const sizes = ["10", "20", "30", "50", "100"];
// Verify we have themes for each category and size
for (const category of categories) {
for (const size of sizes) {
const themeName = `${category}-${size}`;
assert.ok(
themes.includes(themeName as Theme),
`Missing theme: ${themeName}`,
);
}
}
});
test("should generate consistent codenames", async () => {
const { codename } = await import("codenames/all");
// Same input should always produce same output
const result1 = codename(123, "animals-20");
const result2 = codename(123, "animals-20");
assert.strictEqual(result1, result2);
// Different inputs should produce different outputs
const result3 = codename(456, "animals-20");
assert.notStrictEqual(result1, result3);
});
test("should handle different theme types", async () => {
const { codename } = await import("codenames/all");
const testCases = [
{ theme: "animals-20", input: 42 },
{ theme: "cities-30", input: 42 },
{ theme: "colors-10", input: 42 },
{ theme: "food-50", input: 42 },
];
for (const { theme, input } of testCases) {
const result = codename(input, theme as Theme);
assert.strictEqual(typeof result, "string");
assert.ok(result.length > 0);
}
});
test("should throw error for invalid theme", async () => {
const { codename } = await import("codenames/all");
assert.throws(() => {
codename(42, "invalid-theme" as Theme);
}, /Unknown theme/);
});
});