-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreact-addons-text-content.spec.js
75 lines (61 loc) · 1.22 KB
/
react-addons-text-content.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import test from 'ava'
import textContent from '../src'
import React from 'react'
test('should be got text `Hello World`', assert => {
const Com =
<div>
<h1>Hello</h1> World
</div>
assert.is(textContent(Com), `Hello World`)
})
test('render variable', assert => {
const Com =
<div>
<h1>Hello</h1> {'World' + '2'}
</div>
assert.is(textContent(Com), `Hello World2`)
})
test('render variable2', assert => {
const Com =
<div>
<h1>Hello</h1> {1 + 1}
</div>
assert.is(textContent(Com), `Hello 2`)
})
test('should output empty string', assert => {
const Com = <div />
assert.is(textContent(Com), '')
})
test('array children', assert => {
const Com = (
<div>
<h1>Hello</h1> World
{
['a', <h2>b</h2>]
}
</div>
)
assert.is(textContent(Com), `Hello Worldab`)
})
test('array children witth null', assert => {
const Com = (
<div>
<h1>Hello</h1> World
{
['a', null]
}
</div>
)
assert.is(textContent(Com), `Hello Worlda`)
})
test('array component', assert => {
const Com = (
[
<h1>a</h1>, 'b', 'c',
<div>
<h2>x</h2>y
</div>
]
)
assert.is(textContent(Com), `abcxy`)
})