Skip to content

Commit be30cfc

Browse files
committed
Refactor to replace mocha with tape
1 parent e2b8400 commit be30cfc

File tree

2 files changed

+68
-58
lines changed

2 files changed

+68
-58
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
"remark-lint": "^2.0.0",
3131
"remark-slug": "^3.0.0",
3232
"remark-validate-links": "^2.0.0",
33-
"mocha": "^2.0.0"
33+
"tape": "^4.4.0"
3434
},
3535
"scripts": {
36-
"test-api": "mocha --check-leaks test.js",
37-
"test-coverage": "istanbul cover _mocha -- test.js",
36+
"test-api": "node test.js",
37+
"test-coverage": "istanbul cover test.js",
3838
"test-travis": "npm run test-coverage",
3939
"test": "npm run test-api",
4040
"lint-api": "eslint .",

test.js

Lines changed: 65 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,86 @@
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 toString = require('./index.js');
1111

12-
/*
13-
* Methods.
14-
*/
15-
16-
var equal = assert.strictEqual;
17-
var throws = assert.throws;
18-
1912
/*
2013
* Tests.
2114
*/
2215

23-
describe('mdast-util-visit', function () {
24-
it('should fail without node', function () {
25-
throws(function () {
16+
test('mdast-util-to-string', function (t) {
17+
t.throws(
18+
function () {
2619
toString();
27-
});
28-
});
20+
},
21+
'should fail without node'
22+
);
23+
24+
t.equal('foo', toString({
25+
'value': 'foo'
26+
}, 'should not fail on unrecognised nodes'));
27+
28+
t.equal('foo', toString({
29+
'value': 'foo',
30+
'children': [
31+
{
32+
'value': 'foo'
33+
},
34+
{
35+
'alt': 'bar'
36+
},
37+
{
38+
'title': 'baz'
39+
}
40+
]
41+
}), 'should prefer `value` over all others');
2942

30-
it('should not fail on unrecognised nodes', function () {
31-
equal('foo', toString({
32-
'value': 'foo'
33-
}));
34-
});
43+
t.equal('foo', toString({
44+
'value': 'foo',
45+
'alt': 'bar',
46+
'title': 'baz'
47+
}), 'should prefer `value` over `alt` or `title`');
3548

36-
it('should prefer `value`', function () {
37-
equal('foo', toString({
38-
'value': 'foo',
39-
'alt': 'bar',
40-
'title': 'baz'
41-
}));
42-
});
49+
t.equal('bar', toString({
50+
'alt': 'bar',
51+
'title': 'baz'
52+
}), 'should prefer `alt` over `title`');
4353

44-
it('should then prefer `alt`', function () {
45-
equal('bar', toString({
46-
'alt': 'bar',
47-
'title': 'baz'
48-
}));
49-
});
54+
t.equal('baz', toString({
55+
'title': 'baz',
56+
'children': [
57+
{
58+
'value': 'foo'
59+
},
60+
{
61+
'alt': 'bar'
62+
},
63+
{
64+
'title': 'baz'
65+
}
66+
]
67+
}), 'should use `title` over `children`');
5068

51-
it('should then prefer `title`', function () {
52-
equal('baz', toString({
53-
'title': 'baz'
54-
}));
55-
});
69+
t.equal('foobarbaz', toString({
70+
'children': [
71+
{
72+
'value': 'foo'
73+
},
74+
{
75+
'alt': 'bar'
76+
},
77+
{
78+
'title': 'baz'
79+
}
80+
]
81+
}), 'should prefer `children`');
5682

57-
it('should then prefer `children`', function () {
58-
equal('foobarbaz', toString({
59-
'children': [
60-
{
61-
'value': 'foo'
62-
},
63-
{
64-
'alt': 'bar'
65-
},
66-
{
67-
'title': 'baz'
68-
}
69-
]
70-
}));
71-
});
83+
t.equal('', toString({}), 'should fall back on an empty string');
7284

73-
it('should fall back on an empty string', function () {
74-
equal('', toString({}));
75-
});
85+
t.end();
7686
});

0 commit comments

Comments
 (0)