Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
milaGGL committed Dec 23, 2024
1 parent 32bf021 commit 63a7fbb
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions packages/firestore/test/integration/api/query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ import {
writeBatch,
CollectionReference,
WriteBatch,
Firestore
Firestore,
getDocsFromServer
} from '../util/firebase_export';
import {
apiDescribe,
Expand All @@ -66,7 +67,8 @@ import {
withRetry,
withTestCollection,
withTestDb,
checkOnlineAndOfflineResultsMatch
checkOnlineAndOfflineResultsMatch,
toIds
} from '../util/helpers';
import { USE_EMULATOR } from '../util/settings';
import { captureExistenceFilterMismatches } from '../util/testing_hooks_util';
Expand Down Expand Up @@ -2262,6 +2264,35 @@ apiDescribe('Queries', persistence => {
}
);
});

it('snapshot listener sorts cross type numbers same way as server', async () => {
const testDocs = {
'longMin': { value: '-9223372036854775808' },
'longMax': { value: '9223372036854775807' },
'NaN': { value: NaN },
'maxSafeInteger': { value: Number.MAX_SAFE_INTEGER },
'minSafeInteger': { value: Number.MIN_SAFE_INTEGER },
'maxValue': { value: Number.MAX_VALUE },
'negativeMaxValue': { value: -Number.MAX_VALUE },
'minValue': { value: Number.MIN_VALUE },
'negativeMinValue': { value: -Number.MIN_VALUE },
'negativeInfinity': { value: -Infinity },
'positiveInfinity': { value: Infinity }
};

return withTestCollection(persistence, testDocs, async collectionRef => {
const orderedQuery = query(collectionRef, orderBy('value'));

const getSnapshot = await getDocsFromServer(orderedQuery);

const storeEvent = new EventsAccumulator<QuerySnapshot>();
const unsubscribe = onSnapshot(orderedQuery, storeEvent.storeEvent);
const watchSnapshot = await storeEvent.awaitEvent();
expect(toIds(watchSnapshot)).to.deep.equal(toIds(getSnapshot));

unsubscribe();
});
});
});

apiDescribe('Hanging query issue - #7652', persistence => {
Expand Down

0 comments on commit 63a7fbb

Please sign in to comment.