-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathfirestore.spec.ts
45 lines (40 loc) · 1.04 KB
/
firestore.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { expect } from 'chai';
import { initializeApp } from 'firebase-admin/app';
import { getFirestore } from 'firebase-admin/firestore';
import fft = require('../../../src/index');
describe('providers/firestore', () => {
before(() => {
initializeApp();
});
it('clears database with clearFirestoreData', async () => {
const test = fft({ projectId: 'not-a-project' });
const db = getFirestore();
await Promise.all([
db
.collection('test')
.doc('doc1')
.set({}),
db
.collection('test')
.doc('doc1')
.collection('test')
.doc('doc2')
.set({}),
]);
await test.firestore.clearFirestoreData({ projectId: 'not-a-project' });
const docs = await Promise.all([
db
.collection('test')
.doc('doc1')
.get(),
db
.collection('test')
.doc('doc1')
.collection('test')
.doc('doc2')
.get(),
]);
expect(docs[0].exists).to.be.false;
expect(docs[1].exists).to.be.false;
});
});