Skip to content

Commit

Permalink
Merge pull request #11 from grupadotnet/8693hbmzy-add-jest-to-project
Browse files Browse the repository at this point in the history
add tests to project
  • Loading branch information
JN0122 authored Jan 14, 2024
2 parents 832ebd9 + a14f165 commit 50bfd86
Show file tree
Hide file tree
Showing 6 changed files with 896 additions and 33 deletions.
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"lint": "eslint --ext .js,.jsx,.ts,.tsx"
"lint": "eslint --ext .js,.jsx,.ts,.tsx",
"test": "jest"
},
"dependencies": {
"@react-native/metro-config": "^0.73.3",
Expand All @@ -22,6 +23,8 @@
"devDependencies": {
"@babel/core": "^7.20.0",
"@expo/webpack-config": "^19.0.0",
"@testing-library/react-native": "^12.4.3",
"@types/jest": "^29.5.11",
"@types/react": "~18.2.14",
"eslint": "^8.54.0",
"eslint-config-universe": "^12.0.0",
Expand All @@ -30,10 +33,15 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-native": "^4.1.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"jest": "^29.7.0",
"prettier": "^3.1.0",
"react-dom": "18.2.0",
"react-native-web": "~0.19.6",
"react-test-renderer": "^18.2.0",
"typescript": "^5.1.3"
},
"jest": {
"preset": "@testing-library/react-native"
},
"private": true
}
Empty file removed src/components/.placeholder
Empty file.
20 changes: 20 additions & 0 deletions src/components/Button/PrimaryButton.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { fireEvent, render, screen } from '@testing-library/react-native';

import PrimaryButton from './PrimaryButton';

const onPress = jest.fn();

describe('PrimaryButton component tests', () => {
it('properly renders button with provided title', () => {
render(<PrimaryButton title="test" onPress={onPress} />);

expect(screen.getByText('test')).toBeDefined();
});
it('calls provieded onPress method', () => {
render(<PrimaryButton title="test" onPress={onPress} />);

fireEvent(screen.getByText('test'), 'press');

expect(onPress).toHaveBeenCalledTimes(1);
});
});
File renamed without changes.
1 change: 1 addition & 0 deletions src/components/Button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as PrimaryButton } from './PrimaryButton';
Loading

0 comments on commit 50bfd86

Please sign in to comment.