Skip to content

Firestore: database.test.ts: add tests for coercing long polling settings to boolean #7242

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 5 commits into from
Apr 20, 2023
Merged
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
60 changes: 60 additions & 0 deletions packages/firestore/test/unit/api/database.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,66 @@ describe('Settings', () => {
expect(db._getSettings().experimentalForceLongPolling).to.be.false;
});

it('long polling autoDetect=[something truthy] should be coerced to true', () => {
// Use a new instance of Firestore in order to configure settings.
const db = newTestFirestore();
db._setSettings({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
experimentalAutoDetectLongPolling: 1 as any
});
expect(db._getSettings().experimentalAutoDetectLongPolling).to.be.true;
});

it('long polling autoDetect=[something falsy] should be coerced to false', () => {
// Use a new instance of Firestore in order to configure settings.
const db = newTestFirestore();
db._setSettings({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
experimentalAutoDetectLongPolling: 0 as any
});
expect(db._getSettings().experimentalAutoDetectLongPolling).to.be.false;
});

it('long polling autoDetect=null should be coerced to false', () => {
// Use a new instance of Firestore in order to configure settings.
const db = newTestFirestore();
db._setSettings({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
experimentalAutoDetectLongPolling: null as any
});
expect(db._getSettings().experimentalAutoDetectLongPolling).to.be.false;
});

it('long polling force=[something truthy] should be coerced to true', () => {
// Use a new instance of Firestore in order to configure settings.
const db = newTestFirestore();
db._setSettings({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
experimentalForceLongPolling: 'I am truthy' as any
});
expect(db._getSettings().experimentalForceLongPolling).to.be.true;
});

it('long polling force=[something falsy] should be coerced to false', () => {
// Use a new instance of Firestore in order to configure settings.
const db = newTestFirestore();
db._setSettings({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
experimentalForceLongPolling: NaN as any
});
expect(db._getSettings().experimentalForceLongPolling).to.be.false;
});

it('long polling force=null should be coerced to false', () => {
// Use a new instance of Firestore in order to configure settings.
const db = newTestFirestore();
db._setSettings({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
experimentalForceLongPolling: null as any
});
expect(db._getSettings().experimentalForceLongPolling).to.be.false;
});

it('gets settings from useEmulator', () => {
// Use a new instance of Firestore in order to configure settings.
const db = newTestFirestore();
Expand Down