|
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 style = require('./index.js'); |
| 9 | +var test = require('tape'); |
10 | 10 | var remark = require('remark');
|
11 |
| -var assert = require('assert'); |
12 |
| - |
13 |
| -/* |
14 |
| - * Methods. |
15 |
| - */ |
16 |
| - |
17 |
| -var throws = assert.throws; |
18 |
| -var equal = assert.strictEqual; |
| 11 | +var style = require('./index.js'); |
19 | 12 |
|
20 | 13 | /*
|
21 | 14 | * Tests.
|
22 | 15 | */
|
23 | 16 |
|
24 |
| -describe('mdast-util-heading-style', function () { |
25 |
| - it('should fail without node', function () { |
26 |
| - throws(function () { |
| 17 | +test('mdast-util-heading-style', function (t) { |
| 18 | + t.throws( |
| 19 | + function () { |
27 | 20 | style();
|
28 |
| - }); |
29 |
| - }); |
| 21 | + }, |
| 22 | + 'should fail without node' |
| 23 | + ); |
30 | 24 |
|
31 |
| - it('should NOT fail on undetectable nodes', function () { |
32 |
| - equal(null, style({ |
| 25 | + t.equal( |
| 26 | + style({ |
33 | 27 | 'type': 'heading',
|
34 | 28 | 'children': [
|
35 | 29 | {
|
36 | 30 | 'type': 'text',
|
37 | 31 | 'value': 'foo'
|
38 | 32 | }
|
39 | 33 | ]
|
40 |
| - })); |
41 |
| - }); |
42 |
| - |
43 |
| - it('should work', function () { |
44 |
| - equal(style(remark.parse('# ATX').children[0]), 'atx'); |
45 |
| - |
46 |
| - equal(style(remark.parse('# ATX #').children[0]), 'atx-closed'); |
47 |
| - |
48 |
| - equal(style(remark.parse('ATX\n===').children[0]), 'setext'); |
49 |
| - }); |
50 |
| - |
51 |
| - it('should work on ambiguous nodes', function () { |
52 |
| - equal(style(remark.parse('### ATX').children[0]), null); |
53 |
| - |
54 |
| - equal(style(remark.parse('### ATX').children[0], 'atx'), 'atx'); |
55 |
| - |
56 |
| - equal(style(remark.parse('### ATX').children[0], 'setext'), 'setext'); |
57 |
| - }); |
58 |
| - |
59 |
| - it('should work on empty nodes', function () { |
60 |
| - equal( |
61 |
| - style(remark.parse('###### ######').children[0]), |
62 |
| - 'atx-closed' |
63 |
| - ); |
64 |
| - |
65 |
| - equal( |
66 |
| - style(remark.parse('### ###').children[0]), |
67 |
| - 'atx-closed' |
68 |
| - ); |
69 |
| - |
70 |
| - equal( |
71 |
| - style(remark.parse('# #').children[0]), |
72 |
| - 'atx-closed' |
73 |
| - ); |
74 |
| - |
75 |
| - equal( |
76 |
| - style(remark.parse('###### ').children[0], 'atx'), |
77 |
| - 'atx' |
78 |
| - ); |
79 |
| - |
80 |
| - equal( |
81 |
| - style(remark.parse('### ').children[0], 'atx'), |
82 |
| - 'atx' |
83 |
| - ); |
84 |
| - |
85 |
| - equal( |
86 |
| - style(remark.parse('# ').children[0], 'setext'), |
87 |
| - 'atx' |
88 |
| - ); |
89 |
| - |
90 |
| - equal( |
91 |
| - style(remark.parse('###### ').children[0], 'setext'), |
92 |
| - 'setext' |
93 |
| - ); |
94 |
| - |
95 |
| - equal( |
96 |
| - style(remark.parse('### ').children[0], 'setext'), |
97 |
| - 'setext' |
98 |
| - ); |
99 |
| - |
100 |
| - equal( |
101 |
| - style(remark.parse('# ').children[0], 'setext'), |
102 |
| - 'atx' |
103 |
| - ); |
104 |
| - }); |
| 34 | + }), |
| 35 | + null, |
| 36 | + 'should NOT fail on undetectable nodes' |
| 37 | + ); |
| 38 | + |
| 39 | + t.equal( |
| 40 | + style(remark.parse('# ATX').children[0]), |
| 41 | + 'atx', |
| 42 | + 'should detect atx' |
| 43 | + ); |
| 44 | + |
| 45 | + t.equal( |
| 46 | + style(remark.parse('# ATX #').children[0]), |
| 47 | + 'atx-closed', |
| 48 | + 'should detect closed atx' |
| 49 | + ); |
| 50 | + |
| 51 | + t.equal( |
| 52 | + style(remark.parse('ATX\n===').children[0]), |
| 53 | + 'setext', |
| 54 | + 'should detect closed setext' |
| 55 | + ); |
| 56 | + |
| 57 | + t.equal( |
| 58 | + style(remark.parse('### ATX').children[0]), |
| 59 | + null, |
| 60 | + 'should work on ambiguous nodes' |
| 61 | + ); |
| 62 | + |
| 63 | + t.equal( |
| 64 | + style(remark.parse('### ATX').children[0], 'atx'), |
| 65 | + 'atx', |
| 66 | + 'should work on ambiguous nodes (preference to atx)' |
| 67 | + ); |
| 68 | + |
| 69 | + t.equal( |
| 70 | + style(remark.parse('### ATX').children[0], 'setext'), |
| 71 | + 'setext', |
| 72 | + 'should work on ambiguous nodes (preference to setext)' |
| 73 | + ); |
| 74 | + |
| 75 | + t.equal( |
| 76 | + style(remark.parse('###### ######').children[0]), |
| 77 | + 'atx-closed', |
| 78 | + 'should work on empty nodes (#1)' |
| 79 | + ); |
| 80 | + |
| 81 | + t.equal( |
| 82 | + style(remark.parse('### ###').children[0]), |
| 83 | + 'atx-closed', |
| 84 | + 'should work on empty nodes (#2)' |
| 85 | + ); |
| 86 | + |
| 87 | + t.equal( |
| 88 | + style(remark.parse('# #').children[0]), |
| 89 | + 'atx-closed', |
| 90 | + 'should work on empty nodes (#3)' |
| 91 | + ); |
| 92 | + |
| 93 | + t.equal( |
| 94 | + style(remark.parse('###### ').children[0], 'atx'), |
| 95 | + 'atx', |
| 96 | + 'should work on empty nodes (#4)' |
| 97 | + ); |
| 98 | + |
| 99 | + t.equal( |
| 100 | + style(remark.parse('### ').children[0], 'atx'), |
| 101 | + 'atx', |
| 102 | + 'should work on empty nodes (#5)' |
| 103 | + ); |
| 104 | + |
| 105 | + t.equal( |
| 106 | + style(remark.parse('## ').children[0]), |
| 107 | + 'atx', |
| 108 | + 'should work on empty nodes (#6)' |
| 109 | + ); |
| 110 | + |
| 111 | + t.equal( |
| 112 | + style(remark.parse('###### ').children[0], 'setext'), |
| 113 | + 'setext', |
| 114 | + 'should work on empty nodes (#7)' |
| 115 | + ); |
| 116 | + |
| 117 | + t.equal( |
| 118 | + style(remark.parse('### ').children[0], 'setext'), |
| 119 | + 'setext', |
| 120 | + 'should work on empty nodes (#8)' |
| 121 | + ); |
| 122 | + |
| 123 | + t.equal( |
| 124 | + style(remark.parse('## ').children[0], 'setext'), |
| 125 | + 'atx', |
| 126 | + 'should work on empty nodes (#9)' |
| 127 | + ); |
| 128 | + |
| 129 | + t.end(); |
105 | 130 | });
|
0 commit comments