Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

firestore-jest-mock

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firestore-jest-mock - npm Package Compare versions

Comparing version 0.19.0 to 0.20.0

@types/global.d.ts

25

__tests__/mock-firestore.test.js

@@ -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);

16

mocks/firestore.js

@@ -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": "",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc