Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/__tests__/compiler/@prop.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,13 @@ test("@prop target unparsed", () => {
"my-class",
[
{
d: [[[{}, "var", "color-black", 1], ["test"], 1]],
dv: 1,
s: [2, 1],
v: [["__rn-css-current-color", [{}, "var", "color-black", 1]]],
d: [["#000", ["test"]]],
s: [1, 1],
v: [["__rn-css-color", "#000"]],
},
],
],
],
vr: [["color-black", [["#000"]]]],
});

render(<View testID={testID} className="my-class" />);
Expand Down
18 changes: 14 additions & 4 deletions src/__tests__/compiler/compiler.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ test("hello world", () => {
});

test("reads global CSS variables", () => {
const compiled = compile(`
const compiled = compile(
`
@layer theme {
:root, :host {
--color-red-500: oklch(63.7% 0.237 25.331);
}
}`);
}`,
{
inlineVariables: false,
},
);

expect(compiled.stylesheet()).toStrictEqual({
vr: [["color-red-500", [["#fb2c36"]]]],
Expand Down Expand Up @@ -236,11 +241,16 @@ test.skip("animations", () => {
});

test("breaks apart comma separated variables", () => {
const compiled = compile(`
const compiled = compile(
`
:root {
--test: blue, green;
}
`);
`,
{
inlineVariables: false,
},
);

expect(compiled.stylesheet()).toStrictEqual({
vr: [["test", [[["blue", "green"]]]]],
Expand Down
12 changes: 6 additions & 6 deletions src/__tests__/native/box-shadow.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,43 +49,43 @@ test("shadow values - multiple nested variables", () => {
boxShadow: [
{
blurRadius: 0,
color: "red",
color: "#f00",
offsetX: 0,
offsetY: 20,
spreadDistance: 0,
},

{
blurRadius: 0,
color: "green",
color: "#008000",
offsetX: 0,
offsetY: 30,
spreadDistance: 0,
},
{
blurRadius: 0,
color: "purple",
color: "#800080",
offsetX: 0,
offsetY: 40,
spreadDistance: 0,
},
{
blurRadius: 0,
color: "yellow",
color: "#ff0",
offsetX: 0,
offsetY: 50,
spreadDistance: 0,
},
{
blurRadius: 0,
color: "orange",
color: "#ffa500",
offsetX: 0,
offsetY: 60,
spreadDistance: 0,
},
{
blurRadius: 0,
color: "gray",
color: "#808080",
offsetX: 0,
offsetY: 70,
spreadDistance: 0,
Expand Down
4 changes: 1 addition & 3 deletions src/__tests__/native/calc.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ test("calc(var(--variable) + 20%)", () => {
expect(component.type).toBe("View");
expect(component.props).toStrictEqual({
children: undefined,
style: {},
testID,
});
});
Expand All @@ -159,7 +158,6 @@ test("calc(var(--percent) + 20px)", () => {
expect(component.type).toBe("View");
expect(component.props).toStrictEqual({
children: undefined,
style: {},
testID,
});
});
Expand All @@ -185,7 +183,7 @@ test("calc & colors", () => {
expect(component.props).toStrictEqual({
children: undefined,
style: {
backgroundColor: "hsl(120, 90%, 80%)",
backgroundColor: "#9efa9e",
},
testID,
});
Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/native/colors.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe("hsl", () => {
expect(component.type).toBe("View");
expect(component.props).toStrictEqual({
children: undefined,
style: { color: "hsl(0, 84.2%, 60.2%)" },
style: { color: "#ef4444" },
testID,
});
});
Expand All @@ -62,7 +62,7 @@ describe("hsl", () => {
expect(component.type).toBe("View");
expect(component.props).toStrictEqual({
children: undefined,
style: { color: "hsl(0, 84.2%, 60.2%)" },
style: { color: "#ef4444" },
testID,
});
});
Expand Down Expand Up @@ -113,7 +113,7 @@ describe("hsla", () => {
expect(component.type).toBe("View");
expect(component.props).toStrictEqual({
children: undefined,
style: { color: "hsla(0, 84.2%, 60.2%, 60%)" },
style: { color: "#ef444499" },
testID,
});
});
Expand All @@ -130,7 +130,7 @@ describe("hsla", () => {
expect(component.type).toBe("View");
expect(component.props).toStrictEqual({
children: undefined,
style: { color: "hsla(0, 84.2%, 60.2%, 60%)" },
style: { color: "#ef444499" },
testID,
});
});
Expand Down Expand Up @@ -160,7 +160,7 @@ describe("currentcolor", () => {
expect(component.type).toBe("View");
expect(component.props).toStrictEqual({
children: undefined,
style: { color: "red", backgroundColor: "red" },
style: { color: "#f00", backgroundColor: "#f00" },
testID,
});
});
Expand Down
13 changes: 9 additions & 4 deletions src/__tests__/native/text-shadow.test.ios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ import { registerCSS, testID } from "react-native-css/jest";
describe("text-shadow", () => {
test("<offsetX> <offsetY>", () => {
registerCSS(
`.my-class { --my-var: 10px 10px; text-shadow: var(--my-var); }`,
`.my-class {
--my-var: 10px 10px;
text-shadow: var(--my-var);
}`,
);

render(<Text testID={testID} className="my-class" />);

expect(screen.getByTestId(testID).props.style).toStrictEqual({
textShadowColor: "black",
textShadowColor: {
semantic: ["label", "labelColor"],
},
textShadowOffset: {
height: 10,
width: 10,
Expand All @@ -28,7 +33,7 @@ describe("text-shadow", () => {
render(<Text testID={testID} className="my-class" />);

expect(screen.getByTestId(testID).props.style).toStrictEqual({
textShadowColor: "red",
textShadowColor: "#f00",
textShadowOffset: {
height: 10,
width: 10,
Expand All @@ -45,7 +50,7 @@ describe("text-shadow", () => {
render(<Text testID={testID} className="my-class" />);

expect(screen.getByTestId(testID).props.style).toStrictEqual({
textShadowColor: "red",
textShadowColor: "#f00",
textShadowOffset: {
height: 10,
width: 10,
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/native/transform.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe("scale", () => {
).getByTestId(testID);

expect(component.props.style).toStrictEqual({
transform: [{ scale: "2%" }],
transform: [{ scaleX: "2%" }, { scaleY: "2%" }],
});
});

Expand Down
18 changes: 9 additions & 9 deletions src/__tests__/native/variables.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test("inline variable", () => {
});
});

test("combined inline variable", () => {
test("combined inline variables", () => {
registerCSS(`
.my-class-1 { width: var(--my-var); }
.my-class-2 { --my-var: 10px; }
Expand Down Expand Up @@ -142,7 +142,7 @@ test(":root variables", () => {
<View testID={testID} className="my-class" />,
).getByTestId(testID);

expect(component.props.style).toStrictEqual({ color: "red" });
expect(component.props.style).toStrictEqual({ color: "#f00" });
});

test("can apply and set new variables", () => {
Expand All @@ -166,13 +166,13 @@ test("can apply and set new variables", () => {
);

expect(screen.getByTestId(testIDs.one).props.style).toStrictEqual({
color: "red",
color: "#f00",
});
expect(screen.getByTestId(testIDs.two).props.style).toStrictEqual({
color: "red",
color: "#f00",
});
expect(screen.getByTestId(testIDs.three).props.style).toStrictEqual({
color: "green",
color: "#008000",
});
});

Expand All @@ -199,7 +199,7 @@ test("variables will be inherited", () => {
);

expect(screen.getByTestId(testIDs.three).props.style).toStrictEqual({
color: "green",
color: "#008000",
});
});

Expand All @@ -212,7 +212,7 @@ test("useUnsafeVariable", () => {
render(<View testID={testID} className="test" />);
const component = screen.getByTestId(testID);

expect(component.props.style).toStrictEqual({ color: "red" });
expect(component.props.style).toStrictEqual({ color: "#f00" });
});

test("ratio values", () => {
Expand All @@ -224,7 +224,7 @@ test("ratio values", () => {
render(<View testID={testID} className="test" />);
const component = screen.getByTestId(testID);

expect(component.props.style).toStrictEqual({ aspectRatio: "16 / 9" });
expect(component.props.style).toStrictEqual({ aspectRatio: "16/9" });
});

test("VariableContextProvider", () => {
Expand Down Expand Up @@ -269,5 +269,5 @@ test("variable overriding with classes", () => {
);

const component = screen.getByTestId(testID);
expect(component.props.style).toStrictEqual({ color: "red" });
expect(component.props.style).toStrictEqual({ color: "#f00" });
});
Loading