Skip to content

Commit a2c42ed

Browse files
committed
feat(tests): fixture based tests
1 parent 2341ea3 commit a2c42ed

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

testing/deps.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export {
2+
assert,
3+
assertEquals,
4+
} from "https://deno.land/std@0.74.0/testing/asserts.ts";

testing/fixtures.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const comment = [
2+
{
3+
css: "/* body { color: black; } */",
4+
ast: {
5+
type: "stylesheet",
6+
stylesheet: {
7+
rules: [{
8+
type: "comment",
9+
text: " body { color: black; } ",
10+
}],
11+
},
12+
},
13+
},
14+
];

testing/parse_test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { parse } from "../core/parser/parser.ts";
2+
import { comment } from "./fixtures.js";
3+
import { assertEquals } from "./deps.ts";
4+
5+
for (let i = 0; i < comment.length; i++) {
6+
Deno.test(`[parse] - comments (${i})`, function () {
7+
let ast = parse(comment[i].css, { comments: true });
8+
assertEquals(ast, comment[i].ast);
9+
});
10+
}

0 commit comments

Comments
 (0)