Skip to content

Commit

Permalink
Add failing test to query
Browse files Browse the repository at this point in the history
  • Loading branch information
kossnocorp committed Jul 20, 2021
1 parent 17e1dd5 commit 8de1cb2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/query/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ describe('query', () => {
])
})

it('type checks the fields', async () => {
type Location = { mapId: string; name: string; address?: { city: string } }
const locations = collection<Location>('locations')

await Promise.all([
// @ts-expect-error
query(locations, [where(['adddddress', 'city'], '==', 'New York')]),
// No errors, even though the address is optional
query(locations, [where(['address', 'city'], '==', 'New York')])
])
})

it('allows to query using array-contains filter', async () => {
type Tag = 'pets' | 'cats' | 'dogs' | 'food' | 'hotdogs'
type Post = { blogId: string; title: string; tags: Tag[] }
Expand Down
2 changes: 1 addition & 1 deletion test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export function assertType<T>(value: T): asserts value is T {}
export function assertType<Type>(value: Type) {}

export type TypeEqual<T, U> = Exclude<T, U> extends never
? Exclude<U, T> extends never
Expand Down

0 comments on commit 8de1cb2

Please sign in to comment.