This repository has been archived by the owner on Dec 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
144 lines (115 loc) · 3.67 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import React from "react";
import styled from "styled-components";
import Enzyme from "enzyme";
import Adapter from "enzyme-adapter-react-16";
import "jest-styled-components";
import {
xs, sm, md, lg, xl,
breakpoints,
mediaBreakpointUpSm,
mediaBreakpointUpMd,
mediaBreakpointUpLg,
mediaBreakpointUpXl,
mediaBreakpointDownXs,
mediaBreakpointDownSm,
mediaBreakpointDownMd,
mediaBreakpointDownLg,
mediaBreakpointOnlyXs,
mediaBreakpointOnlySm,
mediaBreakpointOnlyMd,
mediaBreakpointOnlyLg,
mediaBreakpointOnlyXl,
mediaBreakpointBetween,
} from "./index";
Enzyme.configure({ adapter: new Adapter() });
const componentFactory = (mediaQuery) => {
const colorBlue = "blue";
const Wrapper = styled.section`
padding: 4em;
background: papayawhip;
`;
const Title = styled.h1`
${mediaQuery`
color: ${colorBlue};
`}
`;
const tree = Enzyme.shallow(
<Wrapper>
<Title>Hello World!</Title>
</Wrapper>,
);
return tree;
};
test("It should export unitless breakpoints", () => {
expect(xs).toEqual(0);
expect(sm).toEqual(576);
expect(md).toEqual(768);
expect(lg).toEqual(992);
expect(xl).toEqual(1200);
});
test("It should export bootstrap breakpoints", () => {
const {
xs: bxs, sm: bsm, md: bmd, lg: blg, xl: bxl,
} = breakpoints;
expect(bxs).toEqual("0px");
expect(bsm).toEqual("576px");
expect(bmd).toEqual("768px");
expect(blg).toEqual("992px");
expect(bxl).toEqual("1200px");
});
test("It should match the mediaBreakpointUpSm snapshot", () => {
const tree = componentFactory(mediaBreakpointUpSm);
expect(tree).toMatchSnapshot();
});
test("It should match the mediaBreakpointUpMd snapshot", () => {
const tree = componentFactory(mediaBreakpointUpMd);
expect(tree).toMatchSnapshot();
});
test("It should match the mediaBreakpointUpLg snapshot", () => {
const tree = componentFactory(mediaBreakpointUpLg);
expect(tree).toMatchSnapshot();
});
test("It should match the mediaBreakpointUpXl snapshot", () => {
const tree = componentFactory(mediaBreakpointUpXl);
expect(tree).toMatchSnapshot();
});
test("It should match the mediaBreakpointDownXs snapshot", () => {
const tree = componentFactory(mediaBreakpointDownXs);
expect(tree).toMatchSnapshot();
});
test("It should match the mediaBreakpointDownSm snapshot", () => {
const tree = componentFactory(mediaBreakpointDownSm);
expect(tree).toMatchSnapshot();
});
test("It should match the mediaBreakpointDownMd snapshot", () => {
const tree = componentFactory(mediaBreakpointDownMd);
expect(tree).toMatchSnapshot();
});
test("It should match the mediaBreakpointDownLg snapshot", () => {
const tree = componentFactory(mediaBreakpointDownLg);
expect(tree).toMatchSnapshot();
});
test("It should match the mediaBreakpointOnlyXs snapshot", () => {
const tree = componentFactory(mediaBreakpointOnlyXs);
expect(tree).toMatchSnapshot();
});
test("It should match the mediaBreakpointOnlySm snapshot", () => {
const tree = componentFactory(mediaBreakpointOnlySm);
expect(tree).toMatchSnapshot();
});
test("It should match the mediaBreakpointOnlyMd snapshot", () => {
const tree = componentFactory(mediaBreakpointOnlyMd);
expect(tree).toMatchSnapshot();
});
test("It should match the mediaBreakpointOnlyLg snapshot", () => {
const tree = componentFactory(mediaBreakpointOnlyLg);
expect(tree).toMatchSnapshot();
});
test("It should match the mediaBreakpointOnlyXl snapshot", () => {
const tree = componentFactory(mediaBreakpointOnlyXl);
expect(tree).toMatchSnapshot();
});
test("It should match the mediaBreakpointBetween snapshot", () => {
const tree = componentFactory(mediaBreakpointBetween(100, 200));
expect(tree).toMatchSnapshot();
});