-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyles.test.ts
More file actions
191 lines (153 loc) · 6.91 KB
/
Copy pathstyles.test.ts
File metadata and controls
191 lines (153 loc) · 6.91 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import { describe, expect, it } from "vitest";
import { buildThemeCSS, CSS, DARK_COLORS, LIGHT_COLORS } from "../src/styles";
describe("LIGHT_COLORS", () => {
it("ライトテーマの背景色を含む", () => {
expect(LIGHT_COLORS).toContain("--gce-bg: #f6f8fa");
expect(LIGHT_COLORS).toContain("--gce-code-bg: #ffffff");
});
it("ライトテーマのボーダー色を含む", () => {
expect(LIGHT_COLORS).toContain("--gce-border: #d0d7de");
});
it("ライトテーマのヘッダー色を含む", () => {
expect(LIGHT_COLORS).toContain("--gce-header-text: #24292f");
expect(LIGHT_COLORS).toContain("--gce-header-link: #0969da");
});
it("ライトテーマの行番号色を含む", () => {
expect(LIGHT_COLORS).toContain("--gce-lineno-color: #6e7781");
expect(LIGHT_COLORS).toContain("--gce-lineno-bg: #f6f8fa");
});
it("ライトテーマの hljs キーワード色を含む", () => {
expect(LIGHT_COLORS).toContain("color: #cf222e");
});
it("ライトテーマの hljs 文字列色を含む", () => {
expect(LIGHT_COLORS).toContain("color: #0a3069");
});
it("ライトテーマの hljs タイトル色を含む", () => {
expect(LIGHT_COLORS).toContain("color: #8250df");
});
it("ライトテーマの hljs 変数色を含む", () => {
expect(LIGHT_COLORS).toContain("color: #953800");
});
it("ライトテーマの hljs コメント色を含む", () => {
expect(LIGHT_COLORS).toContain("color: #6e7781");
});
it("ライトテーマの hljs 数値色を含む", () => {
expect(LIGHT_COLORS).toContain("color: #0550ae");
});
it("ライトテーマの基本テキスト色を含む", () => {
expect(LIGHT_COLORS).toContain("--gce-code-text: #24292f");
});
it("ライトテーマのスクロールバー thumb 色を含む", () => {
expect(LIGHT_COLORS).toContain("--gce-scrollbar-thumb: #afb8c1");
});
});
describe("DARK_COLORS", () => {
it("ダークテーマの背景色を含む", () => {
expect(DARK_COLORS).toContain("--gce-bg: #161b22");
expect(DARK_COLORS).toContain("--gce-code-bg: #0d1117");
});
it("ダークテーマのボーダー色を含む", () => {
expect(DARK_COLORS).toContain("--gce-border: #30363d");
});
it("ダークテーマのヘッダー色を含む", () => {
expect(DARK_COLORS).toContain("--gce-header-text: #e6edf3");
expect(DARK_COLORS).toContain("--gce-header-link: #58a6ff");
});
it("ダークテーマの行番号色を含む", () => {
expect(DARK_COLORS).toContain("--gce-lineno-color: #8b949e");
expect(DARK_COLORS).toContain("--gce-lineno-bg: #161b22");
});
it("ダークテーマの hljs キーワード色を含む", () => {
expect(DARK_COLORS).toContain("color: #ff7b72");
});
it("ダークテーマの hljs 文字列色を含む", () => {
expect(DARK_COLORS).toContain("color: #a5d6ff");
});
it("ダークテーマの hljs タイトル色を含む", () => {
expect(DARK_COLORS).toContain("color: #d2a8ff");
});
it("ダークテーマの hljs 変数色を含む", () => {
expect(DARK_COLORS).toContain("color: #ffa657");
});
it("ダークテーマの hljs コメント色を含む", () => {
expect(DARK_COLORS).toContain("color: #8b949e");
});
it("ダークテーマの hljs 数値色を含む", () => {
expect(DARK_COLORS).toContain("color: #79c0ff");
});
it("ダークテーマの基本テキスト色を含む", () => {
expect(DARK_COLORS).toContain("--gce-code-text: #e6edf3");
});
it("ダークテーマのスクロールバー thumb 色を含む", () => {
expect(DARK_COLORS).toContain("--gce-scrollbar-thumb: #484f58");
});
});
describe("buildThemeCSS", () => {
it('"light" → LIGHT_COLORS のみ返す', () => {
expect(buildThemeCSS("light")).toBe(LIGHT_COLORS);
});
it('"dark" → DARK_COLORS のみ返す', () => {
expect(buildThemeCSS("dark")).toBe(DARK_COLORS);
});
it('"auto" → LIGHT_COLORS を含む', () => {
expect(buildThemeCSS("auto")).toContain(LIGHT_COLORS);
});
it('"auto" → DARK_COLORS が @media (prefers-color-scheme: dark) で囲まれている', () => {
const css = buildThemeCSS("auto");
const mediaStart = css.indexOf("@media (prefers-color-scheme: dark)");
expect(mediaStart).toBeGreaterThan(-1);
// DARK_COLORS はメディアクエリブロック内に含まれる
const afterMedia = css.slice(mediaStart);
expect(afterMedia).toContain(DARK_COLORS);
});
it('"auto" → ダーク側の --gce-code-text が @media ブロック内に現れる', () => {
const css = buildThemeCSS("auto");
const mediaStart = css.indexOf("@media (prefers-color-scheme: dark)");
expect(mediaStart).toBeGreaterThan(-1);
const afterMedia = css.slice(mediaStart);
expect(afterMedia).toContain("--gce-code-text: #e6edf3");
});
it('"auto" → LIGHT_COLORS が DARK_COLORS より前に現れる', () => {
const css = buildThemeCSS("auto");
expect(css.indexOf(LIGHT_COLORS)).toBeLessThan(css.indexOf(DARK_COLORS));
});
it('不明な値 → LIGHT_COLORS にフォールバック', () => {
expect(buildThemeCSS("unknown")).toBe(LIGHT_COLORS);
expect(buildThemeCSS("")).toBe(LIGHT_COLORS);
});
});
describe("CSS (テーマ: light)", () => {
it("テーマ非依存の font-family 変数を含む", () => {
expect(CSS).toContain("--gce-font-family:");
expect(CSS).toContain("--gce-ui-font-family:");
});
it("テーマ非依存の line-height と font-size を含む", () => {
expect(CSS).toContain("--gce-line-height: 1.5em");
expect(CSS).toContain("--gce-font-size: 13px");
});
it("vitest の define により __THEME__ が light に解決され、ライトカラーを含む", () => {
expect(CSS).toContain("--gce-bg: #f6f8fa");
expect(CSS).not.toContain("--gce-bg: #161b22");
});
it("構造 CSS(box-sizing, flex 等)を含む", () => {
expect(CSS).toContain("box-sizing: border-box");
expect(CSS).toContain("display: flex");
});
it("td.gce-code に基本テキスト色の CSS 変数を含む", () => {
const match = CSS.match(/\.gce-container \.gce-table td\.gce-code \{([^}]*)\}/);
expect(match).not.toBeNull();
expect(match![1]).toContain("color: var(--gce-code-text)");
});
it("scrollbar-color サポートブラウザ向けの @supports ブロックを含む", () => {
expect(CSS).toContain("@supports (scrollbar-color: auto)");
expect(CSS).toContain("scrollbar-color: var(--gce-scrollbar-thumb) var(--gce-code-bg)");
expect(CSS).toContain("scrollbar-width: thin");
});
it("scrollbar-color 非対応ブラウザ向けの @supports not ブロックに webkit ルールを含む", () => {
expect(CSS).toContain("@supports not (scrollbar-color: auto)");
expect(CSS).toContain("::-webkit-scrollbar");
expect(CSS).toContain("::-webkit-scrollbar-track");
expect(CSS).toContain("::-webkit-scrollbar-thumb");
expect(CSS).toContain("::-webkit-scrollbar-corner");
});
});