Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Feb 27, 2017
1 parent 7feb19f commit c49a02e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.10.0"
"eslint-plugin-react": "^6.10.0",
"remark": "^7.0.0",
"remark-lint": "^6.0.0",
"tape": "^4.6.3"
},
"scripts": {
"lint": "eslint .",
"build-lib": "babel lib -d dist",
"build": "npm run build-lib",
"test": "npm run lint && npm run build"
"test-api": "node test",
"test": "npm run lint && npm run build && npm run test-api"
},
"bugs": {
"url": "https://github.com/vhf/remark-lint-blank-lines-1-0-2/issues"
Expand Down
42 changes: 42 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const test = require('tape');
const remark = require('remark');
const lint = require('remark-lint');
const alphabetizeLists = require('./');

const processor = remark().use(lint).use(alphabetizeLists);

const nok = `* [An Awesome Book](http://example.com/example.html)
### Example
* [Another Awesome Book](http://example.com/book.html)
* [Some Other Book](http://example.com/other.html)
`;

const ok = `* [An Awesome Book](http://example.com/example.html)
### Example
* [Another Awesome Book](http://example.com/book.html)
* [Some Other Book](http://example.com/other.html)
`;

test('remark-lint-alphabetize-lists', (t) => {
t.deepEqual(
processor.processSync(ok).messages.map(String),
[],
'should work on valid fixtures'
);

t.deepEqual(
processor.processSync(nok).messages.map(String),
[
'1:1-1:53: Incorrect number of blank lines between last section and next heading',
'3:1-3:12: Incorrect number of blank lines between heading and section'
],
'should work on valid fixtures'
);

t.end();
});

0 comments on commit c49a02e

Please sign in to comment.