diff --git a/__tests__/full-setup-library-firestore.test.js b/__tests__/full-setup-library-firestore.test.js index a252d0d..87caaeb 100644 --- a/__tests__/full-setup-library-firestore.test.js +++ b/__tests__/full-setup-library-firestore.test.js @@ -22,6 +22,7 @@ describe.each([ mockBatchCreate, mockSettings, mockOnSnapShot, + mockQueryOnSnapshotUnsubscribe, mockListCollections, mockTimestampNow, mockCreate, @@ -378,7 +379,7 @@ describe.each([ await flushPromises(); - expect(unsubscribe).toBeInstanceOf(Function); + expect(unsubscribe).toBe(mockQueryOnSnapshotUnsubscribe); expect(mockWhere).toHaveBeenCalled(); expect(mockOnSnapShot).toHaveBeenCalled(); }); diff --git a/__tests__/full-setup.test.js b/__tests__/full-setup.test.js index 7b5fae5..434d5c4 100644 --- a/__tests__/full-setup.test.js +++ b/__tests__/full-setup.test.js @@ -34,6 +34,7 @@ describe.each` mockWithConverter, FakeFirestore, mockQueryOnSnapshot, + mockQueryOnSnapshotUnsubscribe, mockTimestampNow, mockRecursiveDelete, } = require('firestore-jest-mock/mocks/firestore'); @@ -411,7 +412,7 @@ describe.each` await flushPromises(); - expect(unsubscribe).toBeInstanceOf(Function); + expect(unsubscribe).toBe(mockQueryOnSnapshotUnsubscribe); expect(mockWhere).toHaveBeenCalled(); expect(mockOnSnapShot).not.toHaveBeenCalled(); expect(mockQueryOnSnapshot).toHaveBeenCalled(); diff --git a/src/mocks/firestore.d.ts b/src/mocks/firestore.d.ts index 7b3f236..ff64911 100644 --- a/src/mocks/firestore.d.ts +++ b/src/mocks/firestore.d.ts @@ -160,6 +160,7 @@ export const mockOffset: jest.Mock; export const mockStartAfter: jest.Mock; export const mockStartAt: jest.Mock; export const mockQueryOnSnapshot: jest.Mock; +export const mockQueryOnSnapshotUnsubscribe: jest.Mock; export const mockWithConverter: jest.Mock; // Mocks exported from Timestamp diff --git a/src/mocks/query.d.ts b/src/mocks/query.d.ts index 10e2953..e363507 100644 --- a/src/mocks/query.d.ts +++ b/src/mocks/query.d.ts @@ -26,5 +26,6 @@ export const mocks: { mockStartAfter: jest.Mock, mockStartAt: jest.Mock, mockQueryOnSnapshot: jest.Mock, + mockQueryOnSnapshotUnsubscribe: jest.Mock, mockWithConverter: jest.Mock, }; diff --git a/src/mocks/query.js b/src/mocks/query.js index 45cff17..c8c1276 100644 --- a/src/mocks/query.js +++ b/src/mocks/query.js @@ -9,6 +9,7 @@ const mockOffset = jest.fn(); const mockStartAfter = jest.fn(); const mockStartAt = jest.fn(); const mockQueryOnSnapshot = jest.fn(); +const mockQueryOnSnapshotUnsubscribe = jest.fn(); const mockWithConverter = jest.fn(); class Query { @@ -140,8 +141,8 @@ class Query { } } - // Returns an unsubscribe function - return () => {}; + // Returns an unsubscribe mock + return mockQueryOnSnapshotUnsubscribe; } } @@ -157,6 +158,7 @@ module.exports = { mockStartAfter, mockStartAt, mockQueryOnSnapshot, + mockQueryOnSnapshotUnsubscribe, mockWithConverter, }, };