Skip to content

Commit f23a0c6

Browse files
committed
test: add jest configuration
1 parent 8a1c23c commit f23a0c6

File tree

7 files changed

+999
-38
lines changed

7 files changed

+999
-38
lines changed

@types/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ export type UseIonHeaderParallxInputResult = {
99
ref: React.MutableRefObject<HTMLElement | null>
1010
}
1111

12-
import {useIonHeaderParallax} from '../src/useIonicHeaderParallax'
12+
import { useIonHeaderParallax } from '../src/useIonicHeaderParallax'
1313

14-
export {
15-
useIonHeaderParallax
16-
}
14+
export { useIonHeaderParallax }

babel.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// babel.config.js
2+
module.exports = {
3+
presets: [
4+
['@babel/preset-env', {targets: {node: 'current'}}],
5+
'@babel/preset-typescript',
6+
],
7+
};

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
2+
module.exports = {
3+
preset: 'ts-jest',
4+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
5+
testEnvironment: 'jsdom',
6+
testMatch: ['<rootDir>/src/**/*.spec.ts', '<rootDir>/src/**/*.spec.tsx'],
7+
8+
};

package.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
"name": "Ahmd Nouira",
77
"email": "ahmnouira@gmail.comm"
88
},
9+
"license": "MIT",
10+
911
"repository": {
1012
"type": "git",
1113
"url": "https://github.com/ahmnouira/ionic-react-header-parallax.git"
1214
},
15+
"readme": "https://github.com/ahmnouira/ionic-react-header-parallax.git#redme",
16+
"homepage": "https://github.com/ahmnouira/ionic-react-header-parallax",
1317
"keywords": [
1418
"ionic"
1519
],
@@ -41,8 +45,11 @@
4145
"prepare": "rimraf dist && yarn build",
4246
"release": "np --no-2fa"
4347
},
44-
"license": "MIT",
4548
"devDependencies": {
49+
"@babel/preset-env": "^7.15.0",
50+
"@babel/preset-react": "^7.14.5",
51+
"@babel/preset-typescript": "^7.15.0",
52+
"@testing-library/react": "^12.0.0",
4653
"@types/jest": "^27.0.1",
4754
"@types/node": "^16.6.1",
4855
"@types/react": "^17.0.18",
@@ -51,14 +58,14 @@
5158
"np": "^7.5.0",
5259
"prettier": "^2.3.2",
5360
"react": "^17.0.2",
61+
"react-dom": "^17.0.2",
5462
"rimraf": "^3.0.2",
63+
"ts-jest": "^27.0.5",
5564
"ts-node": "^10.2.0",
56-
"typescript": "^4.3.5"
65+
"typescript": "^4.3.5",
66+
"yarn": "^1.22.11"
5767
},
58-
5968
"publishConfig": {
6069
"registry": "https://registry.npmjs.org"
6170
}
62-
63-
6471
}

src/IonHeaderParallax.spec.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as React from 'react'
2+
import { render } from '@testing-library/react'
3+
import { IonHeaderParallax } from './IonHeaderParallax'
4+
5+
describe('IonHeaderParallax', () => {
6+
it('should render correctly', () => {
7+
const {} = render(<IonHeaderParallax />)
8+
})
9+
})

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,5 @@
7171
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
7272
},
7373
"include": ["src", "@types"],
74-
"exclude": ["node_modules"]
74+
"exclude": ["node_modules", "src/**/*.spec.tsx", "src/**/*.spec.ts"]
7575
}

yarn.lock

Lines changed: 960 additions & 28 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)