Skip to content

Commit

Permalink
Merge pull request #53 from tylim88/new-features
Browse files Browse the repository at this point in the history
fix(again) #51
  • Loading branch information
tylim88 authored May 5, 2022
2 parents 49bfadb + fc1e40e commit 1f59fd8
Show file tree
Hide file tree
Showing 11 changed files with 408 additions and 301 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@

<br/>

support [@firebase/rules-unit-testing](https://www.npmjs.com/package/@firebase/rules-unit-testing)
support [@firebase/rules-unit-testing](https://firelordjs.com/tests)

The development code, built code and published code are all tested in ci.

Expand Down
42 changes: 42 additions & 0 deletions codeForDoc/src/rulesUnitTesting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import {
runTransaction,
writeBatch,
FirelordRef,
orderBy,
endAt,
startAt,
} from 'firelordjs'
import firebasejson from '../firebase.json'
import {
Expand Down Expand Up @@ -206,4 +209,43 @@ describe('test whether works with rules-unit-testing', () => {
data.a.b.f = []
await readThenCompareWithWriteData(data, ref)
})
it('cursor test', async () => {
const d1 = generateRandomData()
const d2 = generateRandomData()
const d3 = generateRandomData()
const d4 = generateRandomData()
const p1 = setDoc(userRef.doc('1'), d1)
const p2 = setDoc(userRef.doc('2'), d2)
const p3 = setDoc(userRef.doc('3'), d3)
const p4 = setDoc(userRef.doc('4'), d4)

await Promise.all([p1, p2, p3, p4])

expect.assertions(2)

const p5 = getDocs(
query(userRef.collectionGroup(), orderBy('age'), endAt(d3.age as number))
).then(querySnapshot => {
const doc = querySnapshot.docs[querySnapshot.docs.length - 1]
if (doc) {
const data = doc.data()
expect(data.age).toBe(d3.age)
}
})
const p6 = getDocs(
query(
userRef.collectionGroup(),
orderBy('age'),
startAt(d1.age as number)
)
).then(querySnapshot => {
const doc = querySnapshot.docs[0]
if (doc) {
const data = doc.data()
expect(data.age).toBe(d1.age)
}
})

await Promise.all([p5, p6])
})
})
Loading

0 comments on commit 1f59fd8

Please sign in to comment.