@diplodoc/cli-tests 5.39.0 → 5.39.2
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/errors.spec.ts +22 -0
- package/e2e/metadata.spec.ts +8 -2
- package/fixtures/runners/binary.ts +1 -0
- package/fixtures/utils/test.ts +7 -1
- package/mocks/errors/invalid-toc-entry-href/input/.yfm +1 -0
- package/mocks/errors/invalid-toc-entry-href/input/ru/toc.yaml +3 -0
- package/mocks/errors/invalid-toc-root-array/input/.yfm +1 -0
- package/mocks/errors/invalid-toc-root-array/input/ru/toc.yaml +2 -0
- package/package.json +1 -1
package/e2e/errors.spec.ts
CHANGED
|
@@ -48,6 +48,28 @@ describe('Errors', () => {
|
|
|
48
48
|
]);
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
+
test(
|
|
52
|
+
'mocks/errors/invalid-toc-root-array',
|
|
53
|
+
({md, html}: TestResult) => {
|
|
54
|
+
expectErrors(md, [
|
|
55
|
+
'ERR Invalid TOC format in ru/toc.yaml: root value must be an object, got array. Wrap items into an object with the items field.',
|
|
56
|
+
]);
|
|
57
|
+
expectErrors(html, [
|
|
58
|
+
'ERR Invalid TOC format in ru/toc.yaml: root value must be an object, got array. Wrap items into an object with the items field.',
|
|
59
|
+
]);
|
|
60
|
+
},
|
|
61
|
+
['-j1'],
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
test('mocks/errors/invalid-toc-root-array', ({md, html}: TestResult) => {
|
|
65
|
+
expectErrors(md, [
|
|
66
|
+
'ERR Invalid TOC format in ru/toc.yaml: root value must be an object, got array. Wrap items into an object with the items field.',
|
|
67
|
+
]);
|
|
68
|
+
expectErrors(html, [
|
|
69
|
+
'ERR Invalid TOC format in ru/toc.yaml: root value must be an object, got array. Wrap items into an object with the items field.',
|
|
70
|
+
]);
|
|
71
|
+
});
|
|
72
|
+
|
|
51
73
|
test(
|
|
52
74
|
'mocks/errors/max-asset-size',
|
|
53
75
|
({md, html}: TestResult) => {
|
package/e2e/metadata.spec.ts
CHANGED
|
@@ -52,7 +52,10 @@ describe('Allow load custom resources', () => {
|
|
|
52
52
|
(n) => n.includes('support') && n.endsWith('.md'),
|
|
53
53
|
);
|
|
54
54
|
expect(mdIncludePath).toBeTruthy();
|
|
55
|
-
|
|
55
|
+
if (!mdIncludePath) {
|
|
56
|
+
throw new Error('mdIncludePath is null');
|
|
57
|
+
}
|
|
58
|
+
const mdContent = readFileSync(mdIncludePath, 'utf8');
|
|
56
59
|
expect(mdContent).toMatch(/^---/);
|
|
57
60
|
expect(mdContent).toMatch(/csp:/);
|
|
58
61
|
|
|
@@ -64,7 +67,10 @@ describe('Allow load custom resources', () => {
|
|
|
64
67
|
|
|
65
68
|
const htmlPath = findFile(outputPath + '-html', (n) => n === 'page.html');
|
|
66
69
|
expect(htmlPath).toBeTruthy();
|
|
67
|
-
|
|
70
|
+
if (!htmlPath) {
|
|
71
|
+
throw new Error('htmlPath is null');
|
|
72
|
+
}
|
|
73
|
+
const html = readFileSync(htmlPath, 'utf8');
|
|
68
74
|
|
|
69
75
|
expect(html).not.toMatch(/style-src:\s*unsafe-inline/);
|
|
70
76
|
expect(html).not.toMatch(/connect-src:\s*uaas\.yandex\.ru/);
|
package/fixtures/utils/test.ts
CHANGED
|
@@ -104,7 +104,13 @@ function sortBundleTokens(text: string): string {
|
|
|
104
104
|
const sorted = [...slice].sort((a, b) => {
|
|
105
105
|
const ka = a.match(bundleRe)?.[0] ?? '';
|
|
106
106
|
const kb = b.match(bundleRe)?.[0] ?? '';
|
|
107
|
-
|
|
107
|
+
if (ka < kb) {
|
|
108
|
+
return -1;
|
|
109
|
+
}
|
|
110
|
+
if (ka > kb) {
|
|
111
|
+
return 1;
|
|
112
|
+
}
|
|
113
|
+
return 0;
|
|
108
114
|
});
|
|
109
115
|
for (let j = 0; j < sorted.length; j++) {
|
|
110
116
|
lines[start + j] = sorted[j];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
langs: ['ru']
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
langs: ['ru']
|