Skip to content

Commit 4cb2ef1

Browse files
committed
test: 正規表現でセレクタブロックを抽出し color 宣言を堅牢に検証
indexOf("}") による最初の閉じ括弧探索では将来ネストが追加された際に 誤検出するリスクがあるため、正規表現でブロック全体を正確に取得する方式に変更。
1 parent b1d548a commit 4cb2ef1

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

test/styles.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,9 @@ describe("CSS (テーマ: light)", () => {
170170
});
171171

172172
it("td.gce-code に基本テキスト色の CSS 変数を含む", () => {
173-
const selectorIdx = CSS.indexOf(".gce-container .gce-table td.gce-code {");
174-
expect(selectorIdx).toBeGreaterThan(-1);
175-
const blockContent = CSS.slice(selectorIdx);
176-
const blockEnd = blockContent.indexOf("}");
177-
expect(blockContent.slice(0, blockEnd)).toContain("color: var(--gce-code-text)");
173+
const match = CSS.match(/\.gce-container \.gce-table td\.gce-code \{([^}]*)\}/);
174+
expect(match).not.toBeNull();
175+
expect(match![1]).toContain("color: var(--gce-code-text)");
178176
});
179177

180178
it("scrollbar-color サポートブラウザ向けの @supports ブロックを含む", () => {

0 commit comments

Comments
 (0)