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
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,28 @@
"default": "./dist/commonjs/metro/index.js"
}
},
"./compiler": {
"source": "./src/compiler/index.ts",
"import": {
"types": "./dist/typescript/module/src/compiler/index.d.ts",
"default": "./dist/module/compiler/index.js"
},
"require": {
"types": "./dist/typescript/commonjs/src/compiler/index.d.ts",
"default": "./dist/commonjs/compiler/index.js"
}
},
"./jest": {
"source": "./src/jest/index.ts",
"import": {
"types": "./dist/typescript/module/src/jest/index.d.ts",
"default": "./dist/module/jest/index.js"
},
"require": {
"types": "./dist/typescript/commonjs/src/jest/index.d.ts",
"default": "./dist/commonjs/jest/index.js"
}
},
"./babel": {
"source": "./src/babel/index.ts",
"import": {
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/vendor/tailwind.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render, screen } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import { registerCSS, render, screen, testID } from "react-native-css/jest";
import { registerCSS, testID } from "react-native-css/jest";

/**
* Tailwind CSS utilities
Expand Down
9 changes: 4 additions & 5 deletions src/jest/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
/* eslint-disable @typescript-eslint/no-namespace */
import { Dimensions } from "react-native";
import { Appearance, Dimensions } from "react-native";

import { compile, type CompilerOptions } from "../compiler";
import { StyleCollection } from "../runtime/native/injection";
import { colorScheme, dimensions, rem } from "../runtime/native/reactivity";

declare global {
/* eslint-disable @typescript-eslint/no-namespace */
namespace jest {
interface Matchers<R> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
toHaveAnimatedStyle(style?: any): R;
toHaveAnimatedStyle(style?: unknown): R;
}
}
}

export * from "@testing-library/react-native";
export const testID = "react-native-css";

beforeEach(() => {
StyleCollection.styles.clear();
dimensions.set(Dimensions.get("window"));
rem.set(14);
Appearance.setColorScheme(null);
colorScheme.set(null);
});

Expand Down
3 changes: 2 additions & 1 deletion src/runtime/native/__tests__/attributes.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { render, screen } from "@testing-library/react-native";
import { Text } from "react-native-css/components/Text";
import { View } from "react-native-css/components/View";
import { registerCSS, render, screen, testID } from "react-native-css/jest";
import { registerCSS, testID } from "react-native-css/jest";

test(":disabled", () => {
registerCSS(`.test:disabled { width: 10px; }`);
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/native/__tests__/calc.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render, screen } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import { registerCSS, render, screen, testID } from "react-native-css/jest";
import { registerCSS, testID } from "react-native-css/jest";

describe("css", () => {
test("calc(10px + 100px)", () => {
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/native/__tests__/colors.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render, screen } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import { registerCSS, render, screen, testID } from "react-native-css/jest";
import { registerCSS, testID } from "react-native-css/jest";

describe("hsl", () => {
test("inline", () => {
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/native/__tests__/container-queries.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { fireEvent, render, screen } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import { fireEvent, registerCSS, render, screen } from "react-native-css/jest";
import { registerCSS } from "react-native-css/jest";

const parentID = "parent";
const childID = "child";
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/native/__tests__/env.test.ios.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// import { SafeAreaProvider } from "react-native-css/components/SafeAreaProvider";
import { render, screen } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import { registerCSS, render, screen, testID } from "react-native-css/jest";
import { registerCSS, testID } from "react-native-css/jest";

test.skip("safe-area-inset-*", () => {
registerCSS(`.my-class {
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/native/__tests__/grouping.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { fireEvent, render, screen } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import { fireEvent, registerCSS, render, screen } from "react-native-css/jest";
import { registerCSS } from "react-native-css/jest";

// import { getAnimatedStyle } from "react-native-reanimated";

Expand Down
9 changes: 2 additions & 7 deletions src/runtime/native/__tests__/media-query.test.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { PixelRatio } from "react-native";

import { act, render, screen } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import {
act,
registerCSS,
render,
screen,
testID,
} from "react-native-css/jest";
import { registerCSS, testID } from "react-native-css/jest";

import { colorScheme } from "../api";
import { dimensions } from "../reactivity";
Expand Down
15 changes: 8 additions & 7 deletions src/runtime/native/__tests__/selector-prefix.test.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { render, screen } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import { registerCSS, render, testID } from "react-native-css/jest";
import { registerCSS, testID } from "react-native-css/jest";

test("type prefix", () => {
registerCSS(`html .my-class { color: red; }`, {
selectorPrefix: "html",
});

const component = render(
<View testID={testID} className="my-class" />,
).getByTestId(testID);
render(<View testID={testID} className="my-class" />);

const component = screen.getByTestId(testID);

expect(component.props.style).toStrictEqual({
color: "#f00",
Expand All @@ -20,9 +21,9 @@ test("class prefix", () => {
selectorPrefix: ".test",
});

const component = render(
<View testID={testID} className="my-class" />,
).getByTestId(testID);
render(<View testID={testID} className="my-class" />);

const component = screen.getByTestId(testID);

expect(component.props.style).toStrictEqual({
color: "#f00",
Expand Down
9 changes: 2 additions & 7 deletions src/runtime/native/__tests__/selectors.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { act, render, screen } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import {
act,
registerCSS,
render,
screen,
testID,
} from "react-native-css/jest";
import { registerCSS, testID } from "react-native-css/jest";

import { colorScheme } from "../api";

Expand Down
3 changes: 2 additions & 1 deletion src/runtime/native/__tests__/specificity.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { StyleSheet, type ViewProps } from "react-native";

import { fireEvent, render } from "@testing-library/react-native";
import { Text } from "react-native-css/components/Text";
import { fireEvent, registerCSS, render, testID } from "react-native-css/jest";
import { registerCSS, testID } from "react-native-css/jest";

import { styled } from "../api";

Expand Down
9 changes: 2 additions & 7 deletions src/runtime/native/__tests__/style-updating.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { act, render, screen } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import {
act,
registerCSS,
render,
screen,
testID,
} from "react-native-css/jest";
import { registerCSS, testID } from "react-native-css/jest";

test("should update styles", () => {
registerCSS(`
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/native/__tests__/text-shadow.test.ios.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render, screen } from "@testing-library/react-native";
import { Text } from "react-native-css/components/Text";
import { registerCSS, render, screen, testID } from "react-native-css/jest";
import { registerCSS, testID } from "react-native-css/jest";

describe("text-shadow", () => {
test("<offsetX> <offsetY>", () => {
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/native/__tests__/transform.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import { registerCSS, render, testID } from "react-native-css/jest";
import { registerCSS, testID } from "react-native-css/jest";

test("translate", () => {
registerCSS(`.my-class { translate: 10%; }`);
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/native/__tests__/units.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { View } from "react-native";

import { act, registerCSS, renderHook } from "react-native-css/jest";
import { act, renderHook } from "@testing-library/react-native";
import { registerCSS } from "react-native-css/jest";

import { useNativeCss } from "../react/useNativeCss";
import {
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/native/__tests__/upgrading.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { render, screen } from "@testing-library/react-native";
import { Text } from "react-native-css/components/Text";
import { View } from "react-native-css/components/View";
import { registerCSS, render, screen } from "react-native-css/jest";
import { registerCSS } from "react-native-css/jest";

const parentID = "parent";
const childID = "child";
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/native/__tests__/variables.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { memo, useEffect } from "react";
import type { ViewProps } from "react-native";

import { render, screen } from "@testing-library/react-native";
import { View } from "react-native-css/components/View";
import { registerCSS, render, screen, testID } from "react-native-css/jest";
import { registerCSS, testID } from "react-native-css/jest";

import { styled } from "../api";

Expand Down