@diplodoc/cli-tests 5.2.0 → 5.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/e2e/redirects-validation.spec.ts +61 -0
- package/mocks/redirects-validation/extensions-deprecation/input/blah.md +0 -0
- package/mocks/redirects-validation/extensions-deprecation/input/redirects.yaml +5 -0
- package/mocks/redirects-validation/extensions-deprecation/input/toc.yaml +4 -0
- package/mocks/redirects-validation/invalid-regex/input/blah.md +0 -0
- package/mocks/redirects-validation/invalid-regex/input/redirects.yaml +3 -0
- package/mocks/redirects-validation/invalid-regex/input/toc.yaml +4 -0
- package/mocks/redirects-validation/malformed-redirect/input/blah.md +0 -0
- package/mocks/redirects-validation/malformed-redirect/input/redirects.yaml +6 -0
- package/mocks/redirects-validation/malformed-redirect/input/toc.yaml +4 -0
- package/mocks/redirects-validation/same-path/input/blah.md +0 -0
- package/mocks/redirects-validation/same-path/input/redirects.yaml +3 -0
- package/mocks/redirects-validation/same-path/input/toc.yaml +4 -0
- package/mocks/redirects-validation/unparseable/input/blah.md +0 -0
- package/mocks/redirects-validation/unparseable/input/redirects.yaml +11 -0
- package/mocks/redirects-validation/unparseable/input/toc.yaml +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {describe, expect, it} from 'vitest';
|
|
2
|
+
import {TestAdapter, getTestPaths} from '../fixtures';
|
|
3
|
+
|
|
4
|
+
describe('Redirects validation', () => {
|
|
5
|
+
it('should emit an error on an unparseable redirects.yaml', async () => {
|
|
6
|
+
const {inputPath, outputPath} = getTestPaths('mocks/redirects-validation/unparseable');
|
|
7
|
+
|
|
8
|
+
const report = await TestAdapter.build.run(inputPath, outputPath, ['-f', 'md']);
|
|
9
|
+
|
|
10
|
+
expect(report.code).toBe(1);
|
|
11
|
+
expect(report.errors).toContainEqual(expect.stringMatching(/redirects.yaml parsing error/));
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it.skip('should emit a warning when supplied with a `redirects.yaml` that mentions file extensions', async () => {
|
|
15
|
+
const {inputPath, outputPath} = getTestPaths(
|
|
16
|
+
'mocks/redirects-validation/extensions-deprecation',
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const report = await TestAdapter.build.run(inputPath, outputPath, ['-f', 'md']);
|
|
20
|
+
|
|
21
|
+
expect(report.code).toBe(0);
|
|
22
|
+
expect(report.warns).toContainEqual(
|
|
23
|
+
expect.stringMatching(/Redirects with explicit extensions are deprecated./),
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should emit an error when an invalid regular expression pattern is encountered', async () => {
|
|
28
|
+
const {inputPath, outputPath} = getTestPaths('mocks/redirects-validation/invalid-regex');
|
|
29
|
+
|
|
30
|
+
const report = await TestAdapter.build.run(inputPath, outputPath, ['-f', 'md']);
|
|
31
|
+
|
|
32
|
+
expect(report.code).toBe(1);
|
|
33
|
+
expect(report.errors).toContainEqual(
|
|
34
|
+
expect.stringMatching(
|
|
35
|
+
/Redirects configuration results in a non-valid regular expression/,
|
|
36
|
+
),
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should emit an error when a redirect is malformed', async () => {
|
|
41
|
+
const {inputPath, outputPath} = getTestPaths('mocks/redirects-validation/malformed-redirect');
|
|
42
|
+
|
|
43
|
+
const report = await TestAdapter.build.run(inputPath, outputPath, ['-f', 'md']);
|
|
44
|
+
|
|
45
|
+
expect(report.code).toBe(1);
|
|
46
|
+
expect(report.errors).toContainEqual(
|
|
47
|
+
expect.stringMatching(/One of the two parameters is missing/),
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should emit an error when a redirect leads to the same path', async () => {
|
|
52
|
+
const {inputPath, outputPath} = getTestPaths('mocks/redirects-validation/same-path');
|
|
53
|
+
|
|
54
|
+
const report = await TestAdapter.build.run(inputPath, outputPath, ['-f', 'md']);
|
|
55
|
+
|
|
56
|
+
expect(report.code).toBe(1);
|
|
57
|
+
expect(report.errors).toContainEqual(
|
|
58
|
+
expect.stringMatching(/Parameters must be different/),
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|