Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions test/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,7 @@ export default cssExports;
exports[`css-modules-dts-loader > JavaScript Keywords as Class Names > should handle JS keyword class names with namedExport=true 1`] = `
"// This file is automatically generated.
// Please do not change this file!
interface CssExports {
"validClass": string;
"class": string;
"export": string;
"import": string;
}

export const cssExports: CssExports;
export default cssExports;
export const validClass: string;
"
`;

Expand Down
11 changes: 6 additions & 5 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,14 @@
});

const dtsContent = readFile(tmpDir, "styles.module.css.d.ts");
expect(normalizeLineEndings(dtsContent)).toMatchSnapshot();

Check failure on line 244 in test/index.test.ts

View workflow job for this annotation

GitHub Actions / test-and-lint

test/index.test.ts > css-modules-dts-loader > JavaScript Keywords as Class Names > should handle JS keyword class names with namedExport=true

Error: Snapshot `css-modules-dts-loader > JavaScript Keywords as Class Names > should handle JS keyword class names with namedExport=true 1` mismatched - Expected + Received "// This file is automatically generated. // Please do not change this file! - export const validClass: string; + interface CssExports { + "validClass": string; + "class": string; + "export": string; + "import": string; + } + + export const cssExports: CssExports; + export default cssExports; " ❯ test/index.test.ts:244:45

// Should contain all class names
expect(dtsContent).toContain("class");
expect(dtsContent).toContain("export");
expect(dtsContent).toContain("import");
expect(dtsContent).toContain("validClass");
// With namedExport=true, css-loader only exports valid identifiers
// Keywords like 'class', 'export', 'import' are not exported and thus not typed
expect(dtsContent).toContain("export const validClass: string;");
expect(dtsContent).not.toContain("export const class:");
expect(dtsContent).not.toContain("export const export:");
expect(dtsContent).not.toContain("export const import:");
});

it("should handle JS keyword class names with namedExport=false", async () => {
Expand Down
Loading