-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.test.js
executable file
·139 lines (117 loc) · 2.25 KB
/
index.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
const useStyles = require("./index");
const equals = (value, specs) => {
if (value !== specs) console.error(`Test fail: ${value} specs ${specs}`);
else console.info("Test success");
};
const theme = {
palette: {
primary: { base: "blue" }
},
design: {
typo: {
eds: {
fontSize3: {
fontSize: "12px",
fontWeight: "bold"
}
}
},
border: {
small: "2px"
}
}
};
const base = {
style: {
boxShadow:
"0px 2px 4px -1px rgba(0,0,0,0.2), 0px 4px 5px 0px rgba(0,0,0,0.14), 0px 1px 10px 0px rgba(0,0,0,0.12)"
}
};
const state = {
style: {
"&:hover": {
color: "blue"
}
}
};
const nested = {
style: {
"&.my-class p span": {
color: "blue"
}
}
};
const evaluate = {
style: {
border: "solid @theme(design.border.small) @theme(palette.primary.base)"
}
};
const media = {
style: {
"@media(min-width:450px)": {
backgroundColor: "red"
}
}
};
const animations = {
style: {
"@keyframes lds-ripple": {
"0%": {
top: "36px"
},
"100%": {
top: 0
}
}
}
};
const rtl = {
style: {
borderRight: "none"
}
};
const temp1 = useStyles({
props: base,
theme
});
equals(
temp1.stylesheet,
`.${temp1.className}{box-shadow:0px 2px 4px -1px rgba(0,0,0,0.2), 0px 4px 5px 0px rgba(0,0,0,0.14), 0px 1px 10px 0px rgba(0,0,0,0.12)}`
);
const temp2 = useStyles({
props: state,
theme
});
equals(temp2.stylesheet, `.${temp2.className}:hover{color:blue}`);
const temp3 = useStyles({
props: nested,
theme
});
equals(temp3.stylesheet, `.${temp3.className}.my-class p span{color:blue}`);
const temp4 = useStyles({
props: evaluate,
theme
});
equals(
temp4.stylesheet,
`.${temp4.className}{border:solid ${theme.design.border.small} ${theme.palette.primary.base}}`
);
const temp5 = useStyles({
props: media,
theme
});
equals(
temp5.stylesheet,
`@media(min-width:450px){.${temp5.className}{background-color:red}}`
);
const temp6 = useStyles({
props: animations,
theme
});
equals(temp6.stylesheet, "@keyframes lds-ripple{0%{top:36px;}100%{top:0;}}");
const temp7 = useStyles({
props: rtl,
direction: "rtl",
theme
});
equals(temp7.stylesheet, `.${temp7.className}{border-left:none}`);