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