Skip to content

Commit cba9fb8

Browse files
committed
chore(test): fix tests
1 parent d98b126 commit cba9fb8

File tree

9 files changed

+125
-11
lines changed

9 files changed

+125
-11
lines changed

.github/workflows/main.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
node: ["lts/-1", "lts/*"]
15+
node: ["lts/*"]
1616
name: Test on node@v${{ matrix.node }}
1717
steps:
1818
- name: Checkout 🛎️
@@ -33,13 +33,13 @@ jobs:
3333
run: pnpm run lint
3434
- name: TypeScript 🔍
3535
run: pnpm run check
36-
- name: Vitest 🔍
36+
- name: Jest 🔍
3737
run: pnpm run spec
3838
build:
3939
runs-on: ubuntu-latest
4040
strategy:
4141
matrix:
42-
node: ["lts/-1", "lts/*"]
42+
node: ["lts/*"]
4343
name: Build on node@v${{ matrix.node }}
4444
steps:
4545
- name: Checkout 🛎️

eslint.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ const config = [
88
},
99
},
1010
{
11-
// Add this configuration object to ignore specific folders
12-
ignores: [".idea/**", "example/**"],
11+
ignores: [".idea/**", "example/**", "test/**"],
1312
},
1413
{
1514
languageOptions: {
1615
parserOptions: {
1716
project: ["./tsconfig.node.json", "./tsconfig.json"],
18-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1917
tsconfigRootDir: import.meta.dirname,
2018
},
2119
},

jest.config.cjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/** @type {import('jest').Config} */
2+
const config = {
3+
preset: "react-native",
4+
setupFilesAfterEnv: ["./test/setup.ts"],
5+
moduleNameMapper: {
6+
"^src/(.*)$": "<rootDir>/src/$1",
7+
},
8+
transformIgnorePatterns: ["node_modules/(?!(.pnpm/)?(@?react-native.*|react-native-.*|)/)"],
9+
testPathIgnorePatterns: ["/.idea/", "/node_modules/", "/example/", "/dist/"],
10+
};
11+
12+
// eslint-disable-next-line no-undef
13+
module.exports = config;

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"codegen:ios": "rm -rf ios/generated; node node_modules/react-native/scripts/generate-codegen-artifacts.js -p . -t ios -s library",
2626
"lint": "eslint .",
2727
"check": "tsc --noEmit",
28-
"spec": "jest",
28+
"spec": "NODE_OPTIONS=--experimental-require-module jest",
2929
"test": "npm run lint && npm run check && npm run spec",
3030
"prepare": "npm run build"
3131
},
@@ -37,9 +37,11 @@
3737
"@babel/cli": "^7.26.4",
3838
"@babel/core": "^7.26.9",
3939
"@babel/runtime": "^7.26.9",
40+
"@jest/globals": "^29.7.0",
4041
"@mgcrea/eslint-config-react-native": "^0.12.22",
4142
"@react-native/babel-preset": "0.78.0",
4243
"@react-native/typescript-config": "0.78.0",
44+
"@testing-library/react-native": "^13.2.0",
4345
"@types/react": "^19.0.10",
4446
"babel-plugin-module-resolver": "^5.0.2",
4547
"eslint": "^9.21.0",

pnpm-lock.yaml

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/string.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { describe, expect, it } from "@jest/globals";
2+
import { lowercaseFirstLetter } from "./string";
3+
4+
describe("lowercaseFirstLetter", () => {
5+
it("should lowercase the first letter of a string", () => {
6+
expect(lowercaseFirstLetter("Hello")).toBe("hello");
7+
expect(lowercaseFirstLetter("World")).toBe("world");
8+
});
9+
10+
it("should leave the rest of the string unchanged", () => {
11+
expect(lowercaseFirstLetter("Hello World")).toBe("hello World");
12+
expect(lowercaseFirstLetter("JavaScript")).toBe("javaScript");
13+
});
14+
15+
it("should handle empty string", () => {
16+
expect(lowercaseFirstLetter("")).toBe("");
17+
});
18+
19+
it("should handle single character strings", () => {
20+
expect(lowercaseFirstLetter("A")).toBe("a");
21+
expect(lowercaseFirstLetter("Z")).toBe("z");
22+
});
23+
24+
it("should handle strings that already start with lowercase", () => {
25+
expect(lowercaseFirstLetter("already lowercase")).toBe("already lowercase");
26+
});
27+
});

test/setup.ts

Whitespace-only changes.

tsconfig.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
"outDir": "./dist",
1111
"baseUrl": "./",
1212
"paths": {
13-
"src/*": ["src/*"],
14-
"test/*": ["test/*"]
13+
"src/*": ["src/*"]
1514
}
1615
},
17-
"include": ["src", "test"]
16+
"include": ["src"]
1817
}

tsconfig.node.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
"noUncheckedSideEffectImports": true,
2222
"allowJs": true
2323
},
24-
"include": ["*.config.js", "*.config.ts"]
24+
"include": ["*.config.cjs", "*.config.js", "*.config.ts"]
2525
}

0 commit comments

Comments
 (0)