|
1 | | -/** |
2 | | - * @author Titus Wormer |
3 | | - * @copyright 2016 Titus Wormer |
4 | | - * @license MIT |
5 | | - * @module hast:util:whitespace |
6 | | - * @fileoverview Test suite for `whitespace`. |
7 | | - */ |
8 | | - |
9 | 1 | 'use strict'; |
10 | 2 |
|
11 | | -/* eslint-env node */ |
12 | | - |
13 | | -/* |
14 | | - * Module dependencies. |
15 | | - */ |
16 | | - |
| 3 | +/* Dependencies. */ |
17 | 4 | var test = require('tape'); |
18 | 5 | var whitespace = require('./index.js'); |
19 | 6 |
|
20 | | -/* |
21 | | - * Tests. |
22 | | - */ |
23 | | - |
| 7 | +/* Tests. */ |
24 | 8 | test('whitespace', function (t) { |
25 | | - t.equal(whitespace(), false, 'should return `false` without node'); |
26 | | - |
27 | | - t.equal(whitespace({ |
28 | | - 'type': 'element', |
29 | | - 'tagName': 'div' |
30 | | - }), false, 'should return `false` without text'); |
31 | | - |
32 | | - t.equal(whitespace({ |
33 | | - 'type': 'text', |
34 | | - 'value': '\v' |
35 | | - }), false, 'should return `false` for other white-space'); |
36 | | - |
37 | | - t.equal(whitespace({ |
38 | | - 'type': 'text', |
39 | | - 'value': ' \t\r\n\f' |
40 | | - }), true, 'should return `true` for inter-element white-space'); |
41 | | - |
42 | | - t.equal(whitespace({ |
43 | | - 'type': 'text' |
44 | | - }), true, 'should return `true` for `text` without value'); |
45 | | - |
46 | | - t.equal( |
47 | | - whitespace(' \v'), |
48 | | - false, |
49 | | - 'should return `false` for a `string` of text' |
50 | | - ); |
51 | | - |
52 | | - t.equal( |
53 | | - whitespace(' \t\r\n\f'), |
54 | | - true, |
55 | | - 'should return `true` for a `string` of inter-element white-space' |
56 | | - ); |
57 | | - |
58 | | - t.end(); |
| 9 | + t.equal(whitespace(), false, 'should return `false` without node'); |
| 10 | + |
| 11 | + t.equal( |
| 12 | + whitespace({type: 'element', tagName: 'div'}), |
| 13 | + false, |
| 14 | + 'should return `false` without text' |
| 15 | + ); |
| 16 | + |
| 17 | + t.equal( |
| 18 | + whitespace({type: 'text', value: '\v'}), |
| 19 | + false, |
| 20 | + 'should return `false` for other white-space' |
| 21 | + ); |
| 22 | + |
| 23 | + t.equal( |
| 24 | + whitespace({type: 'text', value: ' \t\r\n\f'}), |
| 25 | + true, |
| 26 | + 'should return `true` for inter-element white-space' |
| 27 | + ); |
| 28 | + |
| 29 | + t.equal( |
| 30 | + whitespace({type: 'text'}), |
| 31 | + true, |
| 32 | + 'should return `true` for `text` without value' |
| 33 | + ); |
| 34 | + |
| 35 | + t.equal( |
| 36 | + whitespace(' \v'), |
| 37 | + false, |
| 38 | + 'should return `false` for a `string` of text' |
| 39 | + ); |
| 40 | + |
| 41 | + t.equal( |
| 42 | + whitespace(' \t\r\n\f'), |
| 43 | + true, |
| 44 | + 'should return `true` for a `string` of inter-element white-space' |
| 45 | + ); |
| 46 | + |
| 47 | + t.end(); |
59 | 48 | }); |
0 commit comments