firestore-jest-mock
Advanced tools
Comparing version 0.19.0 to 0.20.0
@@ -42,2 +42,16 @@ const { FakeFirestore } = require('firestore-jest-mock'); | ||
], | ||
checkEmpty: [ | ||
{ | ||
id: 'emptyDocument', | ||
_collections: { | ||
validChildren: { | ||
family: [ | ||
{ id: '1', name: 'One' }, | ||
{ id: '2', name: 'Two' }, | ||
{ id: '3', name: 'Three' }, | ||
], | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
@@ -341,2 +355,13 @@ { simulateQueryFilters }, | ||
test('it returns all results from listDocuments', async () => { | ||
const [emptyDoc] = await db() | ||
.collection('checkEmpty') | ||
.listDocuments(); | ||
expect(emptyDoc).toBeDefined(); | ||
const data = await emptyDoc.get(); | ||
expect(data.exists).toBeTruthy(); | ||
// Contains no data | ||
expect(Object.keys(data.data())).toHaveLength(0); | ||
}); | ||
test('New documents with random ID', async () => { | ||
@@ -343,0 +368,0 @@ expect.assertions(2); |
@@ -496,3 +496,2 @@ const mockCollectionGroup = jest.fn(); | ||
} | ||
return requestedRecords; | ||
@@ -503,3 +502,7 @@ } | ||
mockListDocuments(); | ||
return Promise.resolve([new FakeFirestore.DocumentReference(_randomId(), this)]); | ||
// Returns all documents, including documents with no data but with | ||
// subcollections: see https://googleapis.dev/nodejs/firestore/latest/CollectionReference.html#listDocuments | ||
return Promise.resolve( | ||
this._records().map(rec => new FakeFirestore.DocumentReference(rec.id, this, this.firestore)), | ||
); | ||
} | ||
@@ -514,6 +517,7 @@ | ||
// Make sure we have a 'good enough' document reference | ||
const records = this._records(); | ||
records.forEach(rec => { | ||
rec._ref = new FakeFirestore.DocumentReference(rec.id, this, this.firestore); | ||
}); | ||
const records = this._records().map(rec => ({ | ||
...rec, | ||
_ref: new FakeFirestore.DocumentReference(rec.id, this, this.firestore), | ||
})); | ||
// Firestore does not return documents with no local data | ||
const isFilteringEnabled = this.firestore.options.simulateQueryFilters; | ||
@@ -520,0 +524,0 @@ return buildQuerySnapShot( |
{ | ||
"name": "firestore-jest-mock", | ||
"version": "0.19.0", | ||
"version": "0.20.0", | ||
"description": "Jest helper for mocking Google Cloud Firestore", | ||
@@ -5,0 +5,0 @@ "author": "", |
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
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
211408
4049