-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathdeclarations.test.tsx
More file actions
29 lines (23 loc) · 1.15 KB
/
declarations.test.tsx
File metadata and controls
29 lines (23 loc) · 1.15 KB
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
import { compileWithAutoDebug } from "react-native-css/jest";
// prettier-ignore
const tests = [
["-rn-ripple-color: black;", [{ d: [["black", ["android_ripple", "color"]]], s: [1, 1] }]],
["-rn-ripple-style: borderless;", [{ d: [[true, ["android_ripple", "borderless"]]], s: [1, 1] }]],
["caret-color: black", [{ d: [["#000", ["cursorColor"]]], s: [1, 1] }]],
["fill: black;", [{ d: [["#000", ["fill"]]], s: [1, 1] }]],
["rotate: 3deg;", [{ d: [[[{}, "rotateZ", "3deg"], "rotateZ"]], s: [1, 1] }]],
["rotate: x 3deg;", [{ d: [[[{}, "rotateX", "3deg"], "rotateX"]], s: [1, 1] }]],
["stroke-width: 1px;", [{ d: [[1, ["strokeWidth"]]], s: [1, 1] }]],
["stroke: black;", [{ d: [["#000", ["stroke"]]], s: [1, 1] }]],
] as const;
test.each(tests)("declarations for %s", (declarations, expected) => {
const compiled = compileWithAutoDebug(`.my-class { ${declarations} }`);
const stylesheet = compiled.stylesheet();
const myClassDeclarations = stylesheet.s?.find(
(rule) => rule[0] === "my-class",
)?.[1];
if (!myClassDeclarations) {
throw new Error("No rule found for .my-class");
}
expect(myClassDeclarations).toStrictEqual(expected);
});