forked from act-rules/act-rules.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: ensure each test case in a rule has a title (act-rules#1135)
- Loading branch information
Showing
6 changed files
with
78 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const describeRule = require('../../test-utils/describe-rule') | ||
const getMarkdownAstNodesOfType = require('../../utils/get-markdown-ast-nodes-of-type') | ||
|
||
describeRule('testcase has heading', ({ filename, markdownAST }) => { | ||
/** | ||
* get all headings of test case examples (eg: #### Failed Example 1) | ||
*/ | ||
const testcaseHeadings = getMarkdownAstNodesOfType(markdownAST, 'heading') | ||
.filter(({ depth, children }) => { | ||
return depth === 4 && children && children.length > 0 | ||
}) | ||
.map(({ children }) => { | ||
const [textNode] = children | ||
return textNode.value | ||
}) | ||
|
||
/** | ||
* get code blocks in markdown body | ||
*/ | ||
const testcaseCodeSnippets = getMarkdownAstNodesOfType(markdownAST, 'code') | ||
|
||
/** | ||
* Check if filename has `id` as a part of the name | ||
*/ | ||
test('each testcase has a heading', () => { | ||
const msg = `Not all test cases have headings in ${filename}.` | ||
expect(testcaseHeadings.length, msg).toBe(testcaseCodeSnippets.length) | ||
}) | ||
}) |
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters