|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 |
| -/* eslint-env mocha */ |
| 3 | +/* eslint-env node */ |
4 | 4 |
|
5 | 5 | /*
|
6 | 6 | * Dependencies.
|
7 | 7 | */
|
8 | 8 |
|
9 |
| -var assert = require('assert'); |
| 9 | +var test = require('tape'); |
10 | 10 | var toString = require('./index.js');
|
11 | 11 |
|
12 |
| -/* |
13 |
| - * Methods. |
14 |
| - */ |
15 |
| - |
16 |
| -var equal = assert.strictEqual; |
17 |
| -var throws = assert.throws; |
18 |
| - |
19 | 12 | /*
|
20 | 13 | * Tests.
|
21 | 14 | */
|
22 | 15 |
|
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 () { |
26 | 19 | 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'); |
29 | 42 |
|
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`'); |
35 | 48 |
|
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`'); |
43 | 53 |
|
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`'); |
50 | 68 |
|
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`'); |
56 | 82 |
|
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'); |
72 | 84 |
|
73 |
| - it('should fall back on an empty string', function () { |
74 |
| - equal('', toString({})); |
75 |
| - }); |
| 85 | + t.end(); |
76 | 86 | });
|
0 commit comments