Skip to content

Commit de6d8f3

Browse files
committed
Refactor to replace mocha with tape
1 parent 9244ea0 commit de6d8f3

File tree

2 files changed

+73
-53
lines changed

2 files changed

+73
-53
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: 70 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
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 position = require('./index.js');
1111

12-
/*
13-
* Methods.
14-
*/
15-
16-
var dequal = assert.deepEqual;
17-
1812
/*
1913
* Fixture.
2014
*/
@@ -60,52 +54,78 @@ var pos = {
6054
* Tests.
6155
*/
6256

63-
describe('mdast-util-position', function () {
57+
test('mdast-util-position', function (t) {
6458
['start', 'end'].forEach(function (type) {
65-
describe(type, function () {
59+
t.test(type, function (st) {
6660
var fn = position[type];
6761

68-
it('should not throw without node', function () {
69-
dequal(fn(), pos);
70-
});
71-
72-
it('should get type', function () {
73-
dequal(fn(properties), properties.position[type]);
74-
});
75-
76-
it('should return an empty object without objects', function () {
77-
dequal(fn(objects), pos);
78-
});
79-
80-
it('should return an empty object without values', function () {
81-
dequal(fn(values), pos);
82-
});
83-
84-
it('should return an empty object without position', function () {
85-
dequal(fn(none), pos);
86-
});
62+
st.same(
63+
fn(),
64+
pos,
65+
'should not throw without node'
66+
);
67+
68+
st.same(
69+
fn(properties),
70+
properties.position[type],
71+
'should get type'
72+
);
73+
74+
st.same(
75+
fn(objects),
76+
pos,
77+
'should return an empty object without objects'
78+
);
79+
80+
st.same(
81+
fn(values),
82+
pos,
83+
'should return an empty object without values'
84+
);
85+
86+
st.same(
87+
fn(none),
88+
pos,
89+
'should return an empty object without position'
90+
);
91+
92+
st.end();
8793
});
8894
});
8995

90-
describe('generated', function () {
91-
it('should not throw without node', function () {
92-
assert.equal(position.generated(), true);
93-
});
94-
95-
it('should return false when with properties', function () {
96-
assert.equal(position.generated(properties), false);
97-
});
98-
99-
it('should return false when without properties', function () {
100-
assert.equal(position.generated(objects), true);
101-
});
102-
103-
it('should return false when without objects', function () {
104-
assert.equal(position.generated(values), true);
105-
});
106-
107-
it('should return false when without position', function () {
108-
assert.equal(position.generated(none), true);
109-
});
110-
});
96+
t.test('generated', function (st) {
97+
st.equal(
98+
position.generated(),
99+
true,
100+
'should not throw without node'
101+
);
102+
103+
st.equal(
104+
position.generated(properties),
105+
false,
106+
'should return false when with properties'
107+
);
108+
109+
st.equal(
110+
position.generated(objects),
111+
true,
112+
'should return true when without properties'
113+
);
114+
115+
st.equal(
116+
position.generated(values),
117+
true,
118+
'should return true when without objects'
119+
);
120+
121+
st.equal(
122+
position.generated(none),
123+
true,
124+
'should return true when without position'
125+
);
126+
127+
st.end();
128+
})
129+
130+
t.end();
111131
});

0 commit comments

Comments
 (0)