Skip to content

Commit a0a6f14

Browse files
committed
feat: add comprehensive test coverage, testing infrastructure, and example improvements
- Add test reporting with jest-html-reporter and coverage collection - Implement 100% code coverage across all source files with 24 tests - Add test setup file with jsdom environment configuration - Create comprehensive test suite covering: * useFlutterwave hook with multiple payment scenarios * FlutterWaveButton component with various configurations * useFWScript loading mechanism with retry logic and error handling * closePaymentModal functionality * Parameter validation and edge cases - Add isolated loading state test for script initialization - Update .babelrc.js with @babel/preset-react for JSX support - Update jest.config.js with proper test patterns and coverage exclusions - Update .gitignore to exclude test reports and coverage directories - Add jest-html-reporter and identity-obj-proxy to dev dependencies - Modernize example app with: * Updated App.js with dynamic form configuration * Professional gradient styling and responsive design * Three payment integration methods demonstration * Comprehensive README with test credentials and setup instructions * Updated example package dependencies
1 parent a3f2bd5 commit a0a6f14

12 files changed

Lines changed: 1277 additions & 386 deletions

.babelrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
},
99
},
1010
],
11+
'@babel/preset-react',
1112
'@babel/preset-typescript',
1213
],
1314

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ lib-cov
2222
# Coverage directory used by tools like istanbul
2323
coverage
2424
*.lcov
25+
test-report/
2526

2627
# nyc test coverage
2728
.nyc_output

example/README.md

Lines changed: 73 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,104 @@
1-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
1+
# Flutterwave React v3 Example
22

3-
## Available Scripts
3+
This example demonstrates how to integrate Flutterwave payment gateway into your React application using the `flutterwave-react-v3` package.
44

5-
In the project directory, you can run:
5+
## Features Demonstrated
66

7-
### `yarn start`
7+
**Three Payment Integration Methods:**
8+
- Custom button with `useFlutterwave` hook
9+
- Pre-built `FlutterWaveButton` component
10+
- Custom styled payment buttons
811

9-
Runs the app in the development mode.<br />
10-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
12+
**Real-time Configuration:**
13+
- Dynamic amount input
14+
- Customer information management
15+
- Live payment preview
1116

12-
The page will reload if you make edits.<br />
13-
You will also see any lint errors in the console.
17+
**Modern UI/UX:**
18+
- Responsive design
19+
- Beautiful gradient backgrounds
20+
- Interactive hover effects
21+
- Mobile-friendly layout
1422

15-
### `yarn test`
23+
## Getting Started
1624

17-
Launches the test runner in the interactive watch mode.<br />
18-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
25+
### Prerequisites
1926

20-
### `yarn build`
27+
- Node.js (v14 or higher)
28+
- npm or yarn
29+
- Flutterwave account ([Sign up here](https://flutterwave.com))
2130

22-
Builds the app for production to the `build` folder.<br />
23-
It correctly bundles React in production mode and optimizes the build for the best performance.
31+
### Installation
2432

25-
The build is minified and the filenames include the hashes.<br />
26-
Your app is ready to be deployed!
33+
1. Install dependencies:
2734

28-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
35+
```bash
36+
npm install
37+
# or
38+
yarn install
39+
```
2940

30-
### `yarn eject`
41+
2. Update your Flutterwave public key in `src/App.js`:
3142

32-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
43+
```javascript
44+
const config = {
45+
public_key: "YOUR_FLUTTERWAVE_PUBLIC_KEY", // Replace with your key
46+
// ... other config
47+
};
48+
```
3349

34-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
50+
### Running the Example
3551

36-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
52+
```bash
53+
npm start
54+
# or
55+
yarn start
56+
```
3757

38-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
58+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
3959

40-
## Learn More
60+
## Test Credentials
4161

42-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
62+
For testing purposes, use these Flutterwave test card details:
4363

44-
To learn React, check out the [React documentation](https://reactjs.org/).
64+
- **Card Number:** 5531 8866 5214 2950
65+
- **CVV:** Any 3 digits
66+
- **Expiry:** Any future date
67+
- **PIN:** 3310
68+
- **OTP:** 12345
4569

46-
### Code Splitting
70+
## Package Information
4771

48-
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
72+
This example uses `flutterwave-react-v3` - the official Flutterwave React package with:
4973

50-
### Analyzing the Bundle Size
74+
- ✅ 100% Test Coverage
75+
- ✅ TypeScript Support
76+
- ✅ React 19 Compatible
77+
- ✅ Multiple Payment Options
78+
- ✅ Comprehensive Documentation
5179

52-
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
80+
## Learn More
81+
82+
- [Flutterwave Documentation](https://developer.flutterwave.com/docs)
83+
- [React Documentation](https://react.dev)
84+
- [Package Repository](https://github.com/Flutterwave/React-v3)
85+
86+
## Available Scripts
5387

54-
### Making a Progressive Web App
88+
### `npm start`
5589

56-
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
90+
Runs the app in development mode at [http://localhost:3000](http://localhost:3000).
5791

58-
### Advanced Configuration
92+
### `npm test`
5993

60-
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
94+
Launches the test runner in interactive watch mode.
6195

62-
### Deployment
96+
### `npm run build`
6397

64-
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
98+
Builds the app for production to the `build` folder.
6599

66-
### `yarn build` fails to minify
100+
## Support
67101

68-
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
102+
For issues or questions:
103+
- [GitHub Issues](https://github.com/Flutterwave/React-v3/issues)
104+
- [Flutterwave Support](https://support.flutterwave.com)

0 commit comments

Comments
 (0)