-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHideAt.spec.jsx
90 lines (81 loc) · 2.8 KB
/
HideAt.spec.jsx
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import assert from 'assert';
import { mount } from 'enzyme';
import React from 'react';
import HideAt from './HideAt';
describe('<HideAt />', () => {
it('allows us to set props', () => {
const $ = mount((
<HideAt breakpoint="small" currentBreakpoint="small" />
));
assert.equal($.props().breakpoint, 'small');
assert.equal($.props().currentBreakpoint, 'small');
$.setProps({ breakpoint: 'mediumAndBelow' });
assert.equal($.props().breakpoint, 'mediumAndBelow');
$.setProps({ currentBreakpoint: 'medium' });
assert.equal($.props().currentBreakpoint, 'medium');
});
it('renders child if props are different', () => {
const $ = mount((
<HideAt breakpoint="small" currentBreakpoint="medium">
<div>Hello</div>
</HideAt>
));
assert($.contains(<div>Hello</div>), true);
});
it('renders its children if breakpoint is mediumAndBelow and currentBreakpoint is large', () => {
const $ = mount((
<HideAt breakpoint="mediumAndBelow" currentBreakpoint="large">
<div>Hello</div>
</HideAt>
));
assert($.contains(<div>Hello</div>), true);
});
it('renders its children if breakpoint is large and currentBreakpoint is medium', () => {
const $ = mount((
<HideAt breakpoint="large" currentBreakpoint="medium">
<div>Hello</div>
</HideAt>
));
assert($.contains(<div>Hello</div>), true);
});
it('hides its children if breakpoint is large and currentBreakpoint is large', () => {
const $ = mount((
<HideAt breakpoint="large" currentBreakpoint="large">
<div>Hello</div>
</HideAt>
));
assert.deepStrictEqual($.children().exists(), false);
});
it('hides its children if breakpoint is largeAndBelow and currentBreakpoint is large', () => {
const $ = mount((
<HideAt breakpoint="largeAndBelow" currentBreakpoint="large">
<div>Hello</div>
</HideAt>
));
assert.deepStrictEqual($.children().exists(), false);
});
it('hides its children if breakpoint is mediumAndAbove and currentBreakpoint is large', () => {
const $ = mount((
<HideAt breakpoint="mediumAndAbove" currentBreakpoint="large">
<div>Hello</div>
</HideAt>
));
assert.deepStrictEqual($.children().exists(), false);
});
it('hides its children if breakpoint is medium and currentBreakpoint is medium', () => {
const $ = mount((
<HideAt breakpoint="medium" currentBreakpoint="medium">
<div>Hello</div>
</HideAt>
));
assert.deepStrictEqual($.children().exists(), false);
});
it('hides its children if props are the same', () => {
const $ = mount((
<HideAt breakpoint="mediumAndBelow" currentBreakpoint="medium">
<div>Hello</div>
</HideAt>
));
assert.deepStrictEqual($.children().exists(), false);
});
});