-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
67 lines (61 loc) · 1.19 KB
/
test.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
import test from 'ava'
import React from 'react'
import { create } from 'react-test-renderer'
import {
ScopeProvider,
ScopeConsumer,
withScope,
} from './src'
const Box = props => <div {...props} className='Box' />
const scope = {
Box
}
test('ScopeProvider renders', t => {
const json = create(
<ScopeProvider scope={scope}>
Provider
</ScopeProvider>
).toJSON()
t.snapshot(json)
})
test('ScopeConsumer renders', t => {
const json = create(
<ScopeProvider scope={scope}>
<ScopeConsumer>
{({ Box }) => (
<Box>
Consumer
</Box>
)}
</ScopeConsumer>
</ScopeProvider>
).toJSON()
t.snapshot(json)
})
test('ScopeConsumer renders with defaultScope', t => {
const json = create(
<ScopeConsumer defaultScope={scope}>
{(scope) => (
<Box>
Consumer
</Box>
)}
</ScopeConsumer>
).toJSON()
t.snapshot(json)
})
test('withScope component renders', t => {
const Hello = withScope(({
scope: {
Box
}
}) => (
<Box>Hello</Box>
))
const json = create(
<ScopeProvider scope={scope}>
<Hello />
</ScopeProvider>
).toJSON()
t.snapshot(json)
})