Skip to content

Commit

Permalink
Add integration test using some canonical lists (#142)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
  • Loading branch information
NotWoods and sindresorhus committed Jun 3, 2021
1 parent e8840c7 commit 1c46742
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
8 changes: 7 additions & 1 deletion workflows/main.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ jobs:
fail-fast: false
matrix:
node-version:
- 16
- 14
- 12
- 10
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
env:
github_token: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "test/canonical/awesome-nodejs"]
path = test/canonical/awesome-nodejs
url = https://github.com/sindresorhus/awesome-nodejs.git
[submodule "test/canonical/awesome"]
path = test/canonical/awesome
url = https://github.com/sindresorhus/awesome.git
1 change: 1 addition & 0 deletions test/canonical/awesome
Submodule awesome added at 4e59fb
1 change: 1 addition & 0 deletions test/canonical/awesome-nodejs
Submodule awesome-nodejs added at 94bb62
44 changes: 44 additions & 0 deletions test/integration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import test from 'ava';
import lint from '..';
import findReadmeFile from '../lib/find-readme-file';

/**
Verify there are no `VMessages` in the `VFile`, except for certain rule IDs.
@param {import('ava').ExecutionContext} t - AVA test context.
@param {VFile} vFile - `VFile` with a list of messages.
@param {string[]} expectedRuleIds - Rule IDs for messages you expect to see.
*/
function noUnwantedVMessages(t, vFile, expectedRuleIds) {
const seenRules = new Set(vFile.messages.map(vMessage => vMessage.ruleId));

t.deepEqual([...seenRules], expectedRuleIds);
}

test('awesome', async t => {
const [readme, codeOfConduct] = await lint({filename: findReadmeFile('test/canonical/awesome')});

noUnwantedVMessages(t, readme, [
'match-punctuation',
'awesome-heading'
]);

noUnwantedVMessages(t, codeOfConduct, [
'awesome-code-of-conduct'
]);
});

test('awesome-nodejs', async t => {
const [readme, codeOfConduct] = await lint({filename: findReadmeFile('test/canonical/awesome-nodejs')});

noUnwantedVMessages(t, readme, [
'match-punctuation',
'double-link',
'awesome-heading',
'awesome-list-item'
]);

noUnwantedVMessages(t, codeOfConduct, [
'awesome-code-of-conduct'
]);
});

0 comments on commit 1c46742

Please sign in to comment.