feat: support mock
This commit is contained in:
parent
bd8c72cb23
commit
f3fbbd9717
18
README.md
18
README.md
@ -193,6 +193,24 @@ const Component = () => {
|
||||
};
|
||||
```
|
||||
|
||||
## Jest
|
||||
|
||||
### Overriding Mock logic
|
||||
|
||||
> You can override mock implementation, by replacing its inner functions:
|
||||
|
||||
```typescript
|
||||
import { CaptureProtection } from "react-native-capture-protection/jest/capture-protection-mock";
|
||||
|
||||
...
|
||||
|
||||
test("prevent is called", async () => {
|
||||
await CaptureProtection.prevent();
|
||||
expect(CaptureProtection.prevent).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
🧪 [Methods](./docs/method.md) – All available API methods
|
||||
|
||||
12
jest/capture-protection-mock.js
Normal file
12
jest/capture-protection-mock.js
Normal file
@ -0,0 +1,12 @@
|
||||
const CaptureProtectionMock = {
|
||||
addListener: jest.fn(),
|
||||
hasListener: jest.fn(async () => false),
|
||||
isScreenRecording: jest.fn(async () => false),
|
||||
requestPermission: jest.fn(async () => true),
|
||||
allow: jest.fn(async () => {}),
|
||||
prevent: jest.fn(async () => {}),
|
||||
removeListener: jest.fn(),
|
||||
protectionStatus: jest.fn(async () => true),
|
||||
};
|
||||
|
||||
module.exports = { CaptureProtection: CaptureProtectionMock };
|
||||
15
package.json
15
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-capture-protection",
|
||||
"version": "2.3.1",
|
||||
"version": "2.3.2",
|
||||
"description": "🛡️ A React Native library to prevent and detect for screen capture, screenshots and app switcher for enhanced security. Fully compatible with both Expo and CLI.",
|
||||
"main": "./lib/commonjs/index.js",
|
||||
"module": "./lib/module/index.js",
|
||||
@ -14,6 +14,7 @@
|
||||
"android",
|
||||
"ios",
|
||||
"cpp",
|
||||
"jest",
|
||||
"*.podspec",
|
||||
"!ios/build",
|
||||
"!android/build",
|
||||
@ -57,6 +58,7 @@
|
||||
"@react-native-community/cli": "^20.0.1",
|
||||
"@react-native-community/eslint-config": "^3.0.2",
|
||||
"@release-it/conventional-changelog": "^5.0.0",
|
||||
"@testing-library/react-native": "^12.9.0",
|
||||
"@types/jest": "^28.1.2",
|
||||
"@types/react": "^18",
|
||||
"commitlint": "^17.0.2",
|
||||
@ -65,6 +67,7 @@
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"expo": "^51.0.39",
|
||||
"expo-dev-client": "~5.2.1",
|
||||
"expo-module-scripts": "^3.0.0",
|
||||
"jest": "^28.1.1",
|
||||
"pod-install": "^0.1.0",
|
||||
@ -74,8 +77,7 @@
|
||||
"react-native-builder-bob": "^0.40.13",
|
||||
"release-it": "^15.0.0",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^4.5.2",
|
||||
"expo-dev-client": "~5.2.1"
|
||||
"typescript": "^4.5.2"
|
||||
},
|
||||
"resolutions": {
|
||||
"@react": "17.0.21"
|
||||
@ -94,13 +96,6 @@
|
||||
"node": ">= 16.0.0"
|
||||
},
|
||||
"packageManager": "^yarn@1.22.21",
|
||||
"jest": {
|
||||
"preset": "react-native",
|
||||
"modulePathIgnorePatterns": [
|
||||
"<rootDir>/example/node_modules",
|
||||
"<rootDir>/lib/"
|
||||
]
|
||||
},
|
||||
"commitlint": {
|
||||
"extends": [
|
||||
"@commitlint/config-conventional"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user