-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(FirestoreProvider): Fix error with applying settings to firestore
Setting the 'timestampsInSnapshots' setting needs to be in a call to 'settings', not passed to the 'firestore' function. Fixes #33
- Loading branch information
1 parent
c5dbbbc
commit b5e65d3
Showing
4 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { FirestoreProvider } from '../'; | ||
|
||
test('sets timestampsInSnapshots correctly', () => { | ||
const firestore = {}; | ||
firestore.settings = jest.fn().mockReturnValue(firestore); | ||
const firebase = { | ||
firestore: jest.fn().mockReturnValue(firestore), | ||
}; | ||
|
||
mount( | ||
<FirestoreProvider firebase={firebase}> | ||
<div>Test</div> | ||
</FirestoreProvider>, | ||
); | ||
|
||
expect(firestore.settings).toHaveBeenCalledTimes(1); | ||
expect(firestore.settings).toHaveBeenCalledWith({ | ||
timestampsInSnapshots: false, | ||
}); | ||
|
||
mount( | ||
<FirestoreProvider firebase={firebase} useTimestampsInSnapshots> | ||
<div>Test</div> | ||
</FirestoreProvider>, | ||
); | ||
|
||
expect(firestore.settings).toHaveBeenCalledTimes(2); | ||
expect(firestore.settings).toHaveBeenCalledWith({ | ||
timestampsInSnapshots: true, | ||
}); | ||
}); |