Skip to content

Commit 1cdfa2f

Browse files
committed
feat: move crlf to vitest
1 parent e47b73f commit 1cdfa2f

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

test/crlf.js renamed to test/crlf.test.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
const assert = require("assert")
2-
const parser = require("../src")
1+
import type { VElement, VText } from "../src/ast"
2+
import { describe, it, assert } from "vitest"
3+
import { parseForESLint } from "../src"
34

45
describe("About CRLF tests", () => {
56
it("should not contain CR in `<script>` contents.", () => {
6-
const parsed = parser.parseForESLint(
7+
const parsed = parseForESLint(
78
`<script>\r
89
export default {\r
910
computed: {\r
@@ -23,15 +24,15 @@ describe("About CRLF tests", () => {
2324
sourceType: "module",
2425
},
2526
)
26-
const script = parsed.services
27-
.getDocumentFragment()
27+
const script = parsed
28+
.services!.getDocumentFragment()!
2829
.children.find(
2930
(child) => child.type === "VElement" && child.name === "script",
30-
)
31-
assert.ok(!script.children[0].value.includes("\r"))
31+
) as VElement
32+
assert.ok(!(script.children[0] as VText).value.includes("\r"))
3233
})
33-
it("should contain CRLF in script comment.", async () => {
34-
const parsed = parser.parseForESLint(
34+
it("should contain CRLF in script comment.", () => {
35+
const parsed = parseForESLint(
3536
`<script>\r
3637
export default {\r
3738
computed: {\r
@@ -51,6 +52,6 @@ describe("About CRLF tests", () => {
5152
sourceType: "module",
5253
},
5354
)
54-
assert.ok(parsed.ast.comments[0].value.includes("\r\n"))
55+
assert.ok(parsed.ast.comments![0].value.includes("\r\n"))
5556
})
5657
})

vitest.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { defineConfig} from 'vitest/config'
1+
import { defineConfig } from "vitest/config"
22

33
export default defineConfig({
4-
test: {
5-
include: ['test/parser-options.test.ts']
6-
}
7-
})
4+
test: {
5+
include: ["test/{parser-options,crlf}.test.ts"],
6+
},
7+
})

0 commit comments

Comments
 (0)