-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrule.test.ts
45 lines (38 loc) · 1.03 KB
/
rule.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { expect, test } from 'vitest';
import { format } from 'prettier';
import { prettierLintMd, PARSER_NAME } from '../src/index';
import fs from 'node:fs';
import path from 'node:path';
test(`no-space-in-inline-code`, async () => {
const md = '- right ` const a = 1 ` 你好';
await expect(
format(md, {
parser: PARSER_NAME,
plugins: [
prettierLintMd({
'no-space-in-inline-code': true,
}),
],
}),
).resolves.toBe('- right `const a = 1` 你好\n');
});
test(`no-space-in-inline-code 配置文件`, async () => {
const configPath = path.join(process.cwd(), '.test');
fs.writeFileSync(
configPath,
JSON.stringify({ 'no-space-in-inline-code': true }),
'utf-8',
);
const md = '- right ` const a = 1 ` 你好';
await expect(
format(md, {
parser: PARSER_NAME,
plugins: [
prettierLintMd({
configFile: configPath,
}),
],
}),
).resolves.toBe('- right `const a = 1` 你好\n');
fs.rmSync(configPath);
});