Skip to content

Commit bb06854

Browse files
committed
some baaaasic tests
1 parent 80d1859 commit bb06854

File tree

4 files changed

+5231
-93
lines changed

4 files changed

+5231
-93
lines changed

jest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
4+
testPathIgnorePatterns: ['node_modules', 'lib'],
5+
}

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
77
"scripts": {
8-
"prepare": "yarn build",
9-
"build": "yarn tsc",
8+
"build": "tsc",
109
"release": "auto shipit",
11-
"test": "echo \"Error: no test specified\" && exit 1",
10+
"test": "jest",
1211
"lint": "eslint src/**/*.ts"
1312
},
1413
"peerDependencies": {
@@ -19,13 +18,21 @@
1918
"@auto-it/all-contributors": "^9.10.7",
2019
"@auto-it/first-time-contributor": "^9.10.7",
2120
"@react-native-community/eslint-config": "^0.0.7",
21+
"@testing-library/react-hooks": "^3.2.1",
22+
"@testing-library/react-native": "^5.0.3",
23+
"@types/jest": "^25.1.3",
2224
"@types/react": "^16.9.10",
2325
"@types/react-native": "^0.61.0",
2426
"all-contributors-cli": "^6.13.0",
2527
"auto": "^9.10.7",
2628
"eslint": "^6.8.0",
2729
"eslint-plugin-prettier": "^3.1.2",
30+
"jest": "^25.1.0",
2831
"prettier": "^1.19.1",
32+
"react": "^16.12.0",
33+
"react-native": "^0.61.5",
34+
"react-test-renderer": "^16.12.0",
35+
"ts-jest": "^25.2.1",
2936
"typescript": "^3.6.4"
3037
},
3138
"author": "Nader Dabit",

src/useLayout.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {renderHook} from '@testing-library/react-hooks'
2+
3+
import useLayout from './useLayout'
4+
5+
describe('bla', () => {
6+
it('should increment counter', () => {
7+
const {result} = renderHook(() => useLayout())
8+
9+
expect(result.current.x).toBe(0)
10+
expect(result.current.y).toBe(0)
11+
expect(result.current.width).toBe(0)
12+
expect(result.current.height).toBe(0)
13+
})
14+
})

0 commit comments

Comments
 (0)