Skip to content

Add query() test helper #3408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions packages/firestore/test/unit/api/document_change.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
documentSetAsArray,
key,
orderBy,
path
query
} from '../../util/helpers';
import { firestore } from '../../util/api_helpers';

Expand Down Expand Up @@ -85,31 +85,31 @@ describe('DocumentChange:', () => {
}

it('positions are correct for additions', () => {
const query = Query.atPath(path('c'));
const query1 = query('c');
const initialDocs = [
doc('c/a', 1, {}),
doc('c/c', 1, {}),
doc('c/e', 1, {})
];
const updates = [doc('c/b', 2, {}), doc('c/d', 2, {})];

expectPositions(query, initialDocs, updates);
expectPositions(query1, initialDocs, updates);
});

it('positions are correct for deletions', () => {
const query = Query.atPath(path('c'));
const query1 = query('c');
const initialDocs = [
doc('c/a', 1, {}),
doc('c/b', 1, {}),
doc('c/c', 1, {})
];
const updates = [key('c/a'), key('c/c')];

expectPositions(query, initialDocs, updates);
expectPositions(query1, initialDocs, updates);
});

it('positions are correct for modifications', () => {
const query = Query.atPath(path('c'));
const query1 = query('c');
const initialDocs = [
doc('c/a', 1, { value: 'a-1' }),
doc('c/b', 1, { value: 'b-1' }),
Expand All @@ -120,11 +120,11 @@ describe('DocumentChange:', () => {
doc('c/c', 2, { value: 'c-2' })
];

expectPositions(query, initialDocs, updates);
expectPositions(query1, initialDocs, updates);
});

it('positions are correct for sort order changes', () => {
const query = Query.atPath(path('c')).addOrderBy(orderBy('sort'));
const query1 = query('c', orderBy('sort'));
const initialDocs = [
doc('c/a', 1, { sort: 10 }),
doc('c/b', 1, { sort: 20 }),
Expand All @@ -138,11 +138,11 @@ describe('DocumentChange:', () => {
doc('c/a', 2, { sort: 35 })
];

expectPositions(query, initialDocs, updates);
expectPositions(query1, initialDocs, updates);
});

it('positions are correct for randomly chosen examples', () => {
const query = Query.atPath(path('c')).addOrderBy(orderBy('sort'));
const query1 = query('c', orderBy('sort'));
for (let run = 0; run < 100; run++) {
const initialDocs: Document[] = [];
const updates: Array<DocumentKey | Document> = [];
Expand All @@ -165,7 +165,7 @@ describe('DocumentChange:', () => {
}
}

expectPositions(query, initialDocs, updates);
expectPositions(query1, initialDocs, updates);
}
});
});
Loading