|
1 | | -/** |
2 | | - * @author Titus Wormer |
3 | | - * @copyright 2015 Titus Wormer |
4 | | - * @license MIT |
5 | | - * @module mdast:util:to-string |
6 | | - * @fileoverview Test suite for `mdast-util-to-string`. |
7 | | - */ |
8 | | - |
9 | 1 | 'use strict'; |
10 | 2 |
|
11 | | -/* eslint-env node */ |
12 | | - |
13 | | -/* |
14 | | - * Dependencies. |
15 | | - */ |
16 | | - |
17 | 3 | var test = require('tape'); |
18 | 4 | var toString = require('./index.js'); |
19 | 5 |
|
20 | | -/* |
21 | | - * Tests. |
22 | | - */ |
23 | | - |
24 | 6 | test('mdast-util-to-string', function (t) { |
25 | | - t.throws( |
26 | | - function () { |
27 | | - toString(); |
28 | | - }, |
29 | | - 'should fail without node' |
30 | | - ); |
| 7 | + t.throws( |
| 8 | + function () { |
| 9 | + toString(); |
| 10 | + }, |
| 11 | + 'should fail without node' |
| 12 | + ); |
31 | 13 |
|
32 | | - t.equal('foo', toString({ |
33 | | - 'value': 'foo' |
34 | | - }, 'should not fail on unrecognised nodes')); |
| 14 | + t.equal( |
| 15 | + toString({value: 'foo'}), |
| 16 | + 'foo', |
| 17 | + 'should not fail on unrecognised nodes' |
| 18 | + ); |
35 | 19 |
|
36 | | - t.equal('foo', toString({ |
37 | | - 'value': 'foo', |
38 | | - 'children': [ |
39 | | - { |
40 | | - 'value': 'foo' |
41 | | - }, |
42 | | - { |
43 | | - 'alt': 'bar' |
44 | | - }, |
45 | | - { |
46 | | - 'title': 'baz' |
47 | | - } |
48 | | - ] |
49 | | - }), 'should prefer `value` over all others'); |
| 20 | + t.equal( |
| 21 | + toString({ |
| 22 | + value: 'foo', |
| 23 | + children: [{value: 'foo'}, {alt: 'bar'}, {title: 'baz'}] |
| 24 | + }), |
| 25 | + 'foo', |
| 26 | + 'should prefer `value` over all others' |
| 27 | + ); |
50 | 28 |
|
51 | | - t.equal('foo', toString({ |
52 | | - 'value': 'foo', |
53 | | - 'alt': 'bar', |
54 | | - 'title': 'baz' |
55 | | - }), 'should prefer `value` over `alt` or `title`'); |
| 29 | + t.equal( |
| 30 | + toString({ |
| 31 | + value: 'foo', |
| 32 | + alt: 'bar', |
| 33 | + title: 'baz' |
| 34 | + }), |
| 35 | + 'foo', |
| 36 | + 'should prefer `value` over `alt` or `title`' |
| 37 | + ); |
56 | 38 |
|
57 | | - t.equal('bar', toString({ |
58 | | - 'alt': 'bar', |
59 | | - 'title': 'baz' |
60 | | - }), 'should prefer `alt` over `title`'); |
| 39 | + t.equal( |
| 40 | + toString({alt: 'bar', title: 'baz'}), |
| 41 | + 'bar', |
| 42 | + 'should prefer `alt` over `title`' |
| 43 | + ); |
61 | 44 |
|
62 | | - t.equal('baz', toString({ |
63 | | - 'title': 'baz', |
64 | | - 'children': [ |
65 | | - { |
66 | | - 'value': 'foo' |
67 | | - }, |
68 | | - { |
69 | | - 'alt': 'bar' |
70 | | - }, |
71 | | - { |
72 | | - 'title': 'baz' |
73 | | - } |
74 | | - ] |
75 | | - }), 'should use `title` over `children`'); |
| 45 | + t.equal( |
| 46 | + toString({ |
| 47 | + title: 'baz', |
| 48 | + children: [{value: 'foo'}, {alt: 'bar'}, {title: 'baz'}] |
| 49 | + }), |
| 50 | + 'baz', |
| 51 | + 'should use `title` over `children`' |
| 52 | + ); |
76 | 53 |
|
77 | | - t.equal('foobarbaz', toString({ |
78 | | - 'children': [ |
79 | | - { |
80 | | - 'value': 'foo' |
81 | | - }, |
82 | | - { |
83 | | - 'alt': 'bar' |
84 | | - }, |
85 | | - { |
86 | | - 'title': 'baz' |
87 | | - } |
88 | | - ] |
89 | | - }), 'should prefer `children`'); |
| 54 | + t.equal( |
| 55 | + toString({ |
| 56 | + children: [{value: 'foo'}, {alt: 'bar'}, {title: 'baz'}] |
| 57 | + }), |
| 58 | + 'foobarbaz', |
| 59 | + 'should prefer `children`' |
| 60 | + ); |
90 | 61 |
|
91 | | - t.equal('', toString({}), 'should fall back on an empty string'); |
| 62 | + t.equal( |
| 63 | + toString({}), |
| 64 | + '', |
| 65 | + 'should fall back on an empty string' |
| 66 | + ); |
92 | 67 |
|
93 | | - t.end(); |
| 68 | + t.end(); |
94 | 69 | }); |
0 commit comments