mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-08-24 23:32:19 +10:00
feat: add semantic CSS stylesheets (#3274)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor Agent
parent
4ac19f81b3
commit
d2ffbf9618
@@ -0,0 +1,68 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { compileStylesheet } from "./compile";
|
||||
|
||||
describe("compileStylesheet", () => {
|
||||
it("compiles canonical version-one source", () => {
|
||||
const result = compileStylesheet({
|
||||
languageVersion: 1,
|
||||
text: "@version 1;\nsection { color: #123456; }\n",
|
||||
});
|
||||
|
||||
expect(result.program?.languageVersion).toBe(1);
|
||||
expect(result.diagnostics).toEqual([]);
|
||||
});
|
||||
|
||||
it("warns when version-one source omits the directive", () => {
|
||||
const result = compileStylesheet({ languageVersion: 1, text: "section { color: red; }" });
|
||||
|
||||
expect(result.diagnostics).toContainEqual(
|
||||
expect.objectContaining({ code: "MISSING_VERSION_DIRECTIVE", severity: "warning" }),
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects a directive that disagrees with persisted metadata", () => {
|
||||
const result = compileStylesheet({ languageVersion: 1, text: "@version 2;" });
|
||||
|
||||
expect(result.program).toBeNull();
|
||||
expect(result.diagnostics).toContainEqual(expect.objectContaining({ code: "VERSION_MISMATCH", severity: "error" }));
|
||||
});
|
||||
|
||||
it("rejects duplicate directives", () => {
|
||||
const result = compileStylesheet({ languageVersion: 1, text: "@version 1;\n@version 1;" });
|
||||
|
||||
expect(result.program).toBeNull();
|
||||
expect(result.diagnostics).toContainEqual(
|
||||
expect.objectContaining({ code: "DUPLICATE_VERSION_DIRECTIVE", severity: "error" }),
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects malformed directives", () => {
|
||||
const result = compileStylesheet({ languageVersion: 1, text: "@version one;" });
|
||||
|
||||
expect(result.program).toBeNull();
|
||||
expect(result.diagnostics).toContainEqual(expect.objectContaining({ code: "INVALID_VERSION", severity: "error" }));
|
||||
});
|
||||
|
||||
it("rejects non-positive directives", () => {
|
||||
const result = compileStylesheet({ languageVersion: 1, text: "@version 0;" });
|
||||
|
||||
expect(result.program).toBeNull();
|
||||
expect(result.diagnostics).toContainEqual(expect.objectContaining({ code: "INVALID_VERSION", severity: "error" }));
|
||||
});
|
||||
|
||||
it("rejects unsupported persisted language versions", () => {
|
||||
const result = compileStylesheet({ languageVersion: 2, text: "@version 2;" });
|
||||
|
||||
expect(result.program).toBeNull();
|
||||
expect(result.diagnostics).toContainEqual(
|
||||
expect.objectContaining({ code: "UNSUPPORTED_VERSION", severity: "error" }),
|
||||
);
|
||||
});
|
||||
|
||||
it("does not compile a recovered CSS error", () => {
|
||||
const result = compileStylesheet({ languageVersion: 1, text: "@version 1;\nsection { color red; }" });
|
||||
|
||||
expect(result.program).toBeNull();
|
||||
expect(result.diagnostics).toContainEqual(expect.objectContaining({ code: "CSS_PARSE_ERROR", severity: "error" }));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user