-
-
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.
Merge pull request #1 from cto-af/test
Add tests
- Loading branch information
Showing
10 changed files
with
147 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Data Snap v1 | ||
|
||
exports[`good`] = { | ||
"data": "Test generation:\n\n\u003C!-- Rule Table Start --\u003E\n| **Rule Name** | **Description** | **Recommended** |\n| :- | :- | :-: |\n| [`foo`](.\u002Fdocs\u002Frules\u002Ffoo.md) | Foo test | yes |\n| [`bar`](.\u002Fdocs\u002Frules\u002Fbar.md) | Bar test | no |\n\u003C!-- Rule Table End --\u003E\n\nWith text after.\n", | ||
"meta": { | ||
"expires": null | ||
} | ||
} |
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 @@ | ||
No HTML comments here. |
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,21 @@ | ||
export default { | ||
rules: { | ||
foo: { | ||
meta: { | ||
docs: { | ||
description: 'Foo test', | ||
recommended: true, | ||
}, | ||
}, | ||
}, | ||
bar: { | ||
meta: { | ||
docs: { | ||
description: 'Bar test', | ||
recommended: false, | ||
}, | ||
}, | ||
}, | ||
bad: {}, | ||
}, | ||
}; |
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,7 @@ | ||
{ | ||
"name": "bad", | ||
"version": "0.0.0", | ||
"private": true, | ||
"main": "index.js", | ||
"type": "module" | ||
} |
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,11 @@ | ||
Test generation: | ||
|
||
<!-- Rule Table Start --> | ||
| **Rule Name** | **Description** | **Recommended** | | ||
| :- | :- | :-: | | ||
| [`foo`](./docs/rules/foo.md) | Foo test | yes | | ||
| [`bar`](./docs/rules/bar.md) | Bar test | no | | ||
|
||
<!-- Rule Table End --> | ||
|
||
With text after. |
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,21 @@ | ||
export default { | ||
rules: { | ||
foo: { | ||
meta: { | ||
docs: { | ||
description: 'Foo test', | ||
recommended: true, | ||
}, | ||
}, | ||
}, | ||
bar: { | ||
meta: { | ||
docs: { | ||
description: 'Bar test', | ||
recommended: false, | ||
}, | ||
}, | ||
}, | ||
bad: {}, | ||
}, | ||
}; |
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,7 @@ | ||
{ | ||
"name": "good", | ||
"version": "0.0.0", | ||
"private": true, | ||
"main": "index.js", | ||
"type": "module" | ||
} |
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 |
---|---|---|
@@ -1,8 +1,31 @@ | ||
import assert from 'node:assert'; | ||
import {createRulesTable} from '../lib/index.js'; | ||
import {fileURLToPath} from 'node:url'; | ||
import fs from 'node:fs/promises'; | ||
import path from 'node:path'; | ||
import {rejects} from 'node:assert'; | ||
import snap from 'snappy-snaps'; | ||
// eslint-disable-next-line n/no-unsupported-features/node-builtins | ||
import test from 'node:test'; | ||
|
||
test('index', () => { | ||
// assert.equal(foo(), 2); | ||
const fixtures = fileURLToPath(new URL('./fixtures/', import.meta.url)); | ||
const good = path.resolve(fixtures, 'good'); | ||
const bad = path.resolve(fixtures, 'bad'); | ||
|
||
test('createRulesTable', async() => { | ||
await createRulesTable({cwd: good}); | ||
await snap('good', await fs.readFile(path.join(good, 'README.md'), 'utf8')); | ||
}); | ||
|
||
test('bad README', async() => { | ||
await rejects( | ||
() => createRulesTable({cwd: bad}), | ||
{message: 'Invalid markdown file, needs start/end comments'} | ||
); | ||
}); | ||
|
||
test('bad package.json', async() => { | ||
await rejects( | ||
() => createRulesTable({cwd: '/'}), | ||
{message: 'Unable to find package.json from "/"'} | ||
); | ||
}); |