Skip to content

Commit a7d7372

Browse files
committed
yarn prettier
1 parent 4dcbbee commit a7d7372

File tree

1 file changed

+71
-74
lines changed

1 file changed

+71
-74
lines changed

packages/firestore/test/integration/api_internal/aggregation.test.ts

Lines changed: 71 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -38,88 +38,85 @@ import {
3838
withTestDb
3939
} from '../util/helpers';
4040

41-
apiDescribe(
42-
'Count quries',
43-
(persistence: boolean) => {
44-
it('can run count query getCountFromServer', () => {
45-
const testDocs = {
46-
a: { author: 'authorA', title: 'titleA' },
47-
b: { author: 'authorB', title: 'titleB' }
48-
};
49-
return withTestCollection(persistence, testDocs, async coll => {
50-
const snapshot = await getCountFromServer(coll);
51-
expect(snapshot.data().count).to.equal(2);
52-
});
41+
apiDescribe('Count quries', (persistence: boolean) => {
42+
it('can run count query getCountFromServer', () => {
43+
const testDocs = {
44+
a: { author: 'authorA', title: 'titleA' },
45+
b: { author: 'authorB', title: 'titleB' }
46+
};
47+
return withTestCollection(persistence, testDocs, async coll => {
48+
const snapshot = await getCountFromServer(coll);
49+
expect(snapshot.data().count).to.equal(2);
5350
});
51+
});
5452

55-
it("count query doesn't use converter", () => {
56-
const testDocs = {
57-
a: { author: 'authorA', title: 'titleA' },
58-
b: { author: 'authorB', title: 'titleB' }
59-
};
60-
const throwingConverter = {
61-
toFirestore(obj: never): DocumentData {
62-
throw new Error('should never be called');
63-
},
64-
fromFirestore(snapshot: QueryDocumentSnapshot): never {
65-
throw new Error('should never be called');
66-
}
67-
};
68-
return withTestCollection(persistence, testDocs, async coll => {
69-
const query_ = query(
70-
coll,
71-
where('author', '==', 'authorA')
72-
).withConverter(throwingConverter);
73-
const snapshot = await getCountFromServer(query_);
74-
expect(snapshot.data().count).to.equal(1);
75-
});
53+
it("count query doesn't use converter", () => {
54+
const testDocs = {
55+
a: { author: 'authorA', title: 'titleA' },
56+
b: { author: 'authorB', title: 'titleB' }
57+
};
58+
const throwingConverter = {
59+
toFirestore(obj: never): DocumentData {
60+
throw new Error('should never be called');
61+
},
62+
fromFirestore(snapshot: QueryDocumentSnapshot): never {
63+
throw new Error('should never be called');
64+
}
65+
};
66+
return withTestCollection(persistence, testDocs, async coll => {
67+
const query_ = query(
68+
coll,
69+
where('author', '==', 'authorA')
70+
).withConverter(throwingConverter);
71+
const snapshot = await getCountFromServer(query_);
72+
expect(snapshot.data().count).to.equal(1);
7673
});
74+
});
7775

78-
it('count query supports collection groups', () => {
79-
return withTestDb(persistence, async db => {
80-
const collectionGroupId = doc(collection(db, 'aggregateQueryTest')).id;
81-
const docPaths = [
82-
`${collectionGroupId}/cg-doc1`,
83-
`abc/123/${collectionGroupId}/cg-doc2`,
84-
`zzz${collectionGroupId}/cg-doc3`,
85-
`abc/123/zzz${collectionGroupId}/cg-doc4`,
86-
`abc/123/zzz/${collectionGroupId}`
87-
];
88-
const batch = writeBatch(db);
89-
for (const docPath of docPaths) {
90-
batch.set(doc(db, docPath), { x: 1 });
91-
}
92-
await batch.commit();
93-
const snapshot = await getCountFromServer(
94-
collectionGroup(db, collectionGroupId)
95-
);
96-
expect(snapshot.data().count).to.equal(2);
97-
});
76+
it('count query supports collection groups', () => {
77+
return withTestDb(persistence, async db => {
78+
const collectionGroupId = doc(collection(db, 'aggregateQueryTest')).id;
79+
const docPaths = [
80+
`${collectionGroupId}/cg-doc1`,
81+
`abc/123/${collectionGroupId}/cg-doc2`,
82+
`zzz${collectionGroupId}/cg-doc3`,
83+
`abc/123/zzz${collectionGroupId}/cg-doc4`,
84+
`abc/123/zzz/${collectionGroupId}`
85+
];
86+
const batch = writeBatch(db);
87+
for (const docPath of docPaths) {
88+
batch.set(doc(db, docPath), { x: 1 });
89+
}
90+
await batch.commit();
91+
const snapshot = await getCountFromServer(
92+
collectionGroup(db, collectionGroupId)
93+
);
94+
expect(snapshot.data().count).to.equal(2);
9895
});
96+
});
9997

100-
it('getCountFromServer fails if firestore is terminated', () => {
101-
return withEmptyTestCollection(persistence, async (coll, firestore) => {
102-
await terminate(firestore);
103-
expect(() => getCountFromServer(coll)).to.throw(
104-
'The client has already been terminated.'
105-
);
106-
});
98+
it('getCountFromServer fails if firestore is terminated', () => {
99+
return withEmptyTestCollection(persistence, async (coll, firestore) => {
100+
await terminate(firestore);
101+
expect(() => getCountFromServer(coll)).to.throw(
102+
'The client has already been terminated.'
103+
);
107104
});
105+
});
108106

109-
it("terminate doesn't crash when there is count query in flight", () => {
110-
return withEmptyTestCollection(persistence, async (coll, firestore) => {
111-
void getCountFromServer(coll);
112-
await terminate(firestore);
113-
});
107+
it("terminate doesn't crash when there is count query in flight", () => {
108+
return withEmptyTestCollection(persistence, async (coll, firestore) => {
109+
void getCountFromServer(coll);
110+
await terminate(firestore);
114111
});
112+
});
115113

116-
it('getCountFromServer fails if user is offline', () => {
117-
return withEmptyTestCollection(persistence, async (coll, firestore) => {
118-
await disableNetwork(firestore);
119-
await expect(getCountFromServer(coll)).to.be.eventually.rejectedWith(
120-
'Failed to get count result because the client is offline'
121-
);
122-
});
114+
it('getCountFromServer fails if user is offline', () => {
115+
return withEmptyTestCollection(persistence, async (coll, firestore) => {
116+
await disableNetwork(firestore);
117+
await expect(getCountFromServer(coll)).to.be.eventually.rejectedWith(
118+
'Failed to get count result because the client is offline'
119+
);
123120
});
124-
}
125-
);
121+
});
122+
});

0 commit comments

Comments
 (0)