Skip to content

Commit 8951ecc

Browse files
committed
test: use describe and it
1 parent 33c0f84 commit 8951ecc

File tree

2 files changed

+87
-77
lines changed

2 files changed

+87
-77
lines changed

test/validate-config.js

-77
This file was deleted.

test/validate-config.test.js

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import assert from "node:assert/strict"
2+
import { describe, it } from "node:test"
3+
4+
import { ESLint } from "eslint"
5+
6+
const eslint = new ESLint()
7+
8+
describe("ESLint configuration", () => {
9+
it("should validate correctly JavaScript files", async () => {
10+
const [noErrors] = await eslint.lintFiles(
11+
"test/fixtures/javascript-no-errors.js",
12+
)
13+
const [withErrors] = await eslint.lintFiles(
14+
"test/fixtures/javascript-with-errors.js",
15+
)
16+
assert.strictEqual(
17+
noErrors?.errorCount,
18+
0,
19+
JSON.stringify(noErrors, null, 2),
20+
)
21+
assert.strictEqual(
22+
withErrors?.errorCount,
23+
3,
24+
JSON.stringify(withErrors, null, 2),
25+
)
26+
})
27+
28+
it("should validate correctly TypeScript files", async () => {
29+
const [noErrors] = await eslint.lintFiles(
30+
"test/fixtures/typescript-no-errors.ts",
31+
)
32+
const [withErrors] = await eslint.lintFiles(
33+
"test/fixtures/javascript-with-errors.js",
34+
)
35+
assert.strictEqual(
36+
noErrors?.errorCount,
37+
0,
38+
JSON.stringify(noErrors, null, 2),
39+
)
40+
assert.strictEqual(
41+
withErrors?.errorCount,
42+
3,
43+
JSON.stringify(withErrors, null, 2),
44+
)
45+
})
46+
47+
it("should not use deprecated rules", async () => {
48+
const [javascriptLintResult] = await eslint.lintFiles(
49+
"test/fixtures/javascript-no-errors.js",
50+
)
51+
const [typescriptLintResult] = await eslint.lintFiles(
52+
"test/fixtures/typescript-no-errors.ts",
53+
)
54+
assert.strictEqual(
55+
javascriptLintResult.usedDeprecatedRules.length,
56+
0,
57+
JSON.stringify(javascriptLintResult, null, 2),
58+
)
59+
assert.strictEqual(
60+
typescriptLintResult.usedDeprecatedRules.length,
61+
0,
62+
JSON.stringify(typescriptLintResult, null, 2),
63+
)
64+
})
65+
66+
it("should allow top-level await", async () => {
67+
const [lintResult] = await eslint.lintFiles(
68+
"test/fixtures/top-level-await.mjs",
69+
)
70+
assert.strictEqual(
71+
lintResult?.errorCount,
72+
0,
73+
JSON.stringify(lintResult, null, 2),
74+
)
75+
})
76+
77+
it("should allow to ignore floating promise with void operator (@typescript-eslint/no-floating-promises)", async () => {
78+
const [lintResult] = await eslint.lintFiles(
79+
"test/fixtures/typescript-no-errors-ignore-promise.ts",
80+
)
81+
assert.strictEqual(
82+
lintResult?.errorCount,
83+
0,
84+
JSON.stringify(lintResult, null, 2),
85+
)
86+
})
87+
})

0 commit comments

Comments
 (0)