@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.
@@ -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) => {
@@ -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
- const mdContent = readFileSync(mdIncludePath!, 'utf8');
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
- const html = readFileSync(htmlPath!, 'utf8');
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/);
@@ -29,6 +29,7 @@ export class BinaryRunner implements Runner {
29
29
  console.log(line);
30
30
  }
31
31
  } else if (report.code > 0) {
32
+ // eslint-disable-next-line no-console
32
33
  console.error(stderr);
33
34
  }
34
35
 
@@ -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
- return ka < kb ? -1 : ka > kb ? 1 : 0;
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,3 @@
1
+ items:
2
+ - name: Broken item
3
+ href:
@@ -0,0 +1 @@
1
+ langs: ['ru']
@@ -0,0 +1,2 @@
1
+ - name: Broken root array
2
+ href: index.md
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diplodoc/cli-tests",
3
- "version": "5.39.0",
3
+ "version": "5.39.2",
4
4
  "bin": {
5
5
  "diplodoc-cli-test": "bin.mjs"
6
6
  },