Skip to content

Commit a129939

Browse files
committed
test: create skippable test cases
1 parent e98d69f commit a129939

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

src/linter/rules/__tests__/invalid-change-version.test.mjs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,61 @@ changes:
322322
},
323323
]);
324324
});
325+
326+
it("should skip validations if yaml root node isn't a mapping", () => {
327+
const yamlContent = dedent`
328+
<!-- YAML
329+
- abc
330+
- def
331+
-->`;
332+
333+
const context = {
334+
tree: {
335+
type: 'root',
336+
children: [
337+
{
338+
type: 'html',
339+
value: yamlContent,
340+
position: {
341+
start: { column: 1, line: 7, offset: 103 },
342+
end: { column: 35, line: 7, offset: 137 },
343+
},
344+
},
345+
],
346+
},
347+
report: mock.fn(),
348+
getIssues: mock.fn(),
349+
};
350+
351+
invalidChangeVersion(context);
352+
strictEqual(context.report.mock.callCount(), 0);
353+
});
354+
355+
it('should skip validations if changes node is missing', () => {
356+
const yamlContent = dedent`
357+
<!-- YAML
358+
added: v0.1.91
359+
-->`;
360+
361+
const context = {
362+
tree: {
363+
type: 'root',
364+
children: [
365+
{
366+
type: 'html',
367+
value: yamlContent,
368+
position: {
369+
start: { column: 1, line: 7, offset: 103 },
370+
end: { column: 35, line: 7, offset: 137 },
371+
},
372+
},
373+
],
374+
},
375+
report: mock.fn(),
376+
getIssues: mock.fn(),
377+
};
378+
379+
invalidChangeVersion(context);
380+
strictEqual(context.report.mock.callCount(), 0);
381+
});
325382
});

0 commit comments

Comments
 (0)