-
Notifications
You must be signed in to change notification settings - Fork 0
/
add-combinator.test.mjs
96 lines (85 loc) · 2.31 KB
/
add-combinator.test.mjs
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
import test from "ava"
import addClassName from "./add-class-name.mjs"
import addCombinator from "./add-combinator.mjs"
import store from "./store.mjs"
test.serial (
"given a string representing a combinator and declaration ",
(t) => {
const actual = addCombinator ("$parent>$child", { "color": "red" })
const expect = {
"id": ["$parent", undefined, ">", "$child", undefined],
"key": ">color:red",
"media": "",
"rule": ".ae>.af{color:red}"
}
t.deepEqual (
actual,
expect,
"return an object with 'id' and 'rule' properties"
)
}
)
test.serial (
"given a string representing a combinator and reuse a className",
(t) => {
const actual = addCombinator ("$child $thing", { "color": "blue" })
const expect = {
"id": ["$child", undefined, " ", "$thing", undefined],
"key": " color:blue",
"media": "",
"rule": ".af .ag{color:blue}"
}
t.deepEqual (
actual,
expect,
"return an object with 'id' and 'rule' properties"
)
}
)
test.serial (
"given a string representing a combinator and reusing both classNames",
(t) => {
const actual = addCombinator ("$parent+$thing", { "color": "green" })
const expect = {
"id": ["$parent", undefined, "+", "$thing", undefined],
"key": "+color:green",
"media": "",
"rule": ".ae+.ag{color:green}"
}
t.deepEqual (
actual,
expect,
"return an object with 'id' and 'rule' properties"
)
}
)
test.serial (
"given the function 'addClassName', when called with '$child', media query, and ':hover' (2)",
(t) => {
const actual = addClassName ("$stuff", "", ":hover")
const expect = {
"id": "ah",
"key": ":hover$stuff",
"media": "",
"rule": undefined
}
t.deepEqual (actual, expect, "then should return the id string 'ah'")
}
)
test.serial (
"given a string representing a combinator and declaration",
(t) => {
const actual = addCombinator ("$parent>$stuff:hover", { "color": "red" }, "")
const expect = {
"id": ["$parent", undefined, ">", "$stuff", ":hover"],
"key": ">:hovercolor:red",
"media": "",
"rule": ".ae>.ah:hover{color:red}"
}
t.deepEqual (
actual,
expect,
"return an object with 'id' and 'rule' properties"
)
}
)