Skip to content

Commit c740b51

Browse files
committed
Refactor to replace mocha with tape
1 parent 618011f commit c740b51

File tree

2 files changed

+43
-24
lines changed

2 files changed

+43
-24
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
"remark-lint": "^2.0.0",
3434
"remark-slug": "^3.0.0",
3535
"remark-validate-links": "^2.0.0",
36-
"mocha": "^2.0.0"
36+
"tape": "^4.0.0"
3737
},
3838
"scripts": {
39-
"test-api": "mocha --check-leaks test.js",
40-
"test-coverage": "istanbul cover _mocha -- test.js",
39+
"test-api": "node test.js",
40+
"test-coverage": "istanbul cover test.js",
4141
"test-travis": "npm run test-coverage",
4242
"test": "npm run test-api",
4343
"lint-api": "eslint .",

test.js

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
'use strict';
22

3-
/* eslint-env mocha */
3+
/* eslint-env node */
44

55
/*
66
* Dependencies.
77
*/
88

9-
var assert = require('assert');
9+
var test = require('tape');
1010
var remark = require('remark');
1111
var definitions = require('./index.js');
1212

1313
/*
1414
* Tests.
1515
*/
1616

17-
describe('mdast-util-definitions', function () {
18-
it('should fail without node', function () {
19-
assert.throws(function () {
17+
test('mdast-util-definitions', function (t) {
18+
var getDefinition;
19+
var ast;
20+
21+
t.throws(
22+
function () {
2023
definitions();
21-
}, /mdast-util-definitions expected node/);
22-
});
24+
},
25+
/mdast-util-definitions expected node/,
26+
'should fail without node'
27+
);
2328

24-
it('should work', function () {
25-
var ast = remark.parse('[example]: http://example.com "Example"');
26-
var getDefinition = definitions(ast);
29+
ast = remark.parse('[example]: http://example.com "Example"');
30+
getDefinition = definitions(ast);
2731

28-
assert.deepEqual(getDefinition('example'), {
32+
t.deepEqual(
33+
getDefinition('example'),
34+
{
2935
'type': 'definition',
3036
'identifier': 'example',
3137
'link': 'http://example.com',
@@ -41,16 +47,22 @@ describe('mdast-util-definitions', function () {
4147
},
4248
'indent': []
4349
}
44-
});
50+
},
51+
'should return a definition'
52+
);
4553

46-
assert.deepEqual(getDefinition('foo'), null);
47-
});
54+
t.equal(
55+
getDefinition('foo'),
56+
null,
57+
'should return null when not found'
58+
);
4859

49-
it('should work on weird identifiers', function () {
50-
var ast = remark.parse('[__proto__]: http://proto.com "Proto"');
51-
var getDefinition = definitions(ast);
60+
ast = remark.parse('[__proto__]: http://proto.com "Proto"');
61+
getDefinition = definitions(ast);
5262

53-
assert.deepEqual(getDefinition('__proto__'), {
63+
t.deepEqual(
64+
getDefinition('__proto__'),
65+
{
5466
'type': 'definition',
5567
'identifier': '__proto__',
5668
'link': 'http://proto.com',
@@ -66,8 +78,15 @@ describe('mdast-util-definitions', function () {
6678
},
6779
'indent': []
6880
}
69-
});
81+
},
82+
'should work on weird identifiers'
83+
);
84+
85+
t.deepEqual(
86+
getDefinition('toString'),
87+
null,
88+
'should work on weird identifiers when not found'
89+
);
7090

71-
assert.deepEqual(getDefinition('toString'), null);
72-
});
91+
t.end();
7392
});

0 commit comments

Comments
 (0)