firestore-jest-mock
Advanced tools
Comparing version 0.18.0 to 0.19.0
@@ -5,1 +5,2 @@ export { FakeFirestore } from './mocks/firestore'; | ||
export { mockGoogleCloudFirestore } from './mocks/googleCloudFirestore'; | ||
export { mockReactNativeFirestore } from './mocks/reactNativeFirebaseFirestore'; |
@@ -5,2 +5,3 @@ const { FakeFirestore } = require('./mocks/firestore'); | ||
const { mockGoogleCloudFirestore } = require('./mocks/googleCloudFirestore'); | ||
const { mockReactNativeFirestore } = require('./mocks/reactNativeFirebaseFirestore'); | ||
@@ -10,4 +11,5 @@ module.exports = { | ||
mockFirebase, | ||
mockReactNativeFirestore, | ||
FakeFirestore, | ||
FakeAuth, | ||
}; |
{ | ||
"name": "firestore-jest-mock", | ||
"version": "0.18.0", | ||
"version": "0.19.0", | ||
"description": "Jest helper for mocking Google Cloud Firestore", | ||
@@ -39,2 +39,3 @@ "author": "", | ||
"@babel/preset-env": "^7.5.5", | ||
"@react-native-firebase/firestore": "^15.1.1", | ||
"@types/jest": "^26.0.20", | ||
@@ -41,0 +42,0 @@ "@typescript-eslint/eslint-plugin": "^4.17.0", |
@@ -25,2 +25,3 @@ # Mock Firestore | ||
- [`@google-cloud/firestore` compatibility](#google-cloudfirestore-compatibility) | ||
- [`@react-native-firebase/firestore` compatibility](#react-native-firebasefirestore-compatibility) | ||
- [Subcollections](#subcollections) | ||
@@ -31,5 +32,5 @@ - [What would you want to test?](#what-would-you-want-to-test) | ||
- [Additional options](#additional-options) | ||
- [includeIdsInData](#includeidsindata) | ||
- [mutable](#mutable) | ||
- [simulateQueryFilters](#simulateQueryFilters) | ||
- [`includeIdsInData`](#includeidsindata) | ||
- [`mutable`](#mutable) | ||
- [`simulateQueryFilters`](#simulatequeryfilters) | ||
- [Functions you can test](#functions-you-can-test) | ||
@@ -163,2 +164,38 @@ - [Firestore](#firestore) | ||
### `@react-native-firebase/firestore` compatibility | ||
If you use `@react-native-firebase/firestore`, use `mockGoogleCloudFirestore` instead of `mockFirebase` in all the documentation. | ||
```js | ||
const { mockGoogleCloudFirestore } = require('firestore-jest-mock'); | ||
mockGoogleCloudFirestore({ | ||
database: { | ||
users: [ | ||
{ id: 'abc123', name: 'Homer Simpson' }, | ||
{ id: 'abc456', name: 'Lisa Simpson' }, | ||
], | ||
posts: [{ id: '123abc', title: 'Really cool title' }], | ||
}, | ||
}); | ||
const { mockCollection } = require('firestore-jest-mock/mocks/firestore'); | ||
test('testing stuff', () => { | ||
const { Firestore } = require('@react-native-firebase/firestore'); | ||
const firestore = new Firestore(); | ||
return firestore | ||
.collection('users') | ||
.get() | ||
.then(userDocs => { | ||
expect(mockCollection).toHaveBeenCalledWith('users'); | ||
expect(userDocs[0].name).toEqual('Homer Simpson'); | ||
}); | ||
}); | ||
``` | ||
_Note: Authentication with `@react-native-firebase/firestore` is not handled in the same way as with `firebase`. | ||
The `Auth` module is not available for `@react-native-firebase/firestore` compatibility._ | ||
### Subcollections | ||
@@ -165,0 +202,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
210403
56
4020
483
22
4