Skip to content

Commit

Permalink
test: update tests for macos
Browse files Browse the repository at this point in the history
  • Loading branch information
russellwheatley committed Aug 5, 2024
1 parent c703130 commit c1d39fa
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions packages/firestore/e2e/firestore.e2e.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Platform } from 'react-native';

/*
* Copyright (c) 2016-present Invertase Limited & Contributors
*
Expand Down Expand Up @@ -335,18 +337,30 @@ describe('firestore()', function () {
describe('FirestorePersistentCacheIndexManager', function () {
describe('if persistence is enabled', function () {
it('should enableIndexAutoCreation()', async function () {
if (Platform.other) {
// Not supported on web lite sdk
return;
}
const db = firebase.firestore();
const indexManager = db.persistentCacheIndexManager();
await indexManager.enableIndexAutoCreation();
});

it('should disableIndexAutoCreation()', async function () {
if (Platform.other) {
// Not supported on web lite sdk
return;
}
const db = firebase.firestore();
const indexManager = db.persistentCacheIndexManager();
await indexManager.disableIndexAutoCreation();
});

it('should deleteAllIndexes()', async function () {
if (Platform.other) {
// Not supported on web lite sdk
return;
}
const db = firebase.firestore();
const indexManager = db.persistentCacheIndexManager();
await indexManager.deleteAllIndexes();
Expand All @@ -355,12 +369,32 @@ describe('firestore()', function () {

describe('if persistence is disabled', function () {
it('should return `null` when calling `persistentCacheIndexManager()`', async function () {
if (Platform.other) {
// Not supported on web lite sdk
return;
}
const secondFirestore = firebase.app('secondaryFromNative').firestore();
secondFirestore.settings({ persistence: false });
const indexManager = secondFirestore.persistentCacheIndexManager();
should.equal(indexManager, null);
});
});

describe('macOS should throw exception when calling `persistentCacheIndexManager()`', function () {
it('should throw an exception', async function () {
if (!Platform.other) {
return;
}

try {
const db = firebase.firestore();
db.persistentCacheIndexManager();
throw new Error('Did not throw an Error.');
} catch (e) {
e.message.should.containEql('not supported');
}
});
});
});
});

Expand Down Expand Up @@ -718,6 +752,10 @@ describe('firestore()', function () {
describe('FirestorePersistentCacheIndexManager', function () {
describe('if persistence is enabled', function () {
it('should enableIndexAutoCreation()', async function () {
if (Platform.other) {
// Not supported on web lite sdk
return;
}
const {
getFirestore,
getPersistentCacheIndexManager,
Expand All @@ -729,6 +767,10 @@ describe('firestore()', function () {
});

it('should disableIndexAutoCreation()', async function () {
if (Platform.other) {
// Not supported on web lite sdk
return;
}
const {
getFirestore,
getPersistentCacheIndexManager,
Expand All @@ -740,6 +782,10 @@ describe('firestore()', function () {
});

it('should deleteAllIndexes()', async function () {
if (Platform.other) {
// Not supported on web lite sdk
return;
}
const { getFirestore, getPersistentCacheIndexManager, deleteAllPersistentCacheIndexes } =
firestoreModular;
const db = getFirestore();
Expand All @@ -750,6 +796,10 @@ describe('firestore()', function () {

describe('if persistence is disabled', function () {
it('should return `null` when calling `persistentCacheIndexManager()`', async function () {
if (Platform.other) {
// Not supported on web lite sdk
return;
}
const { initializeFirestore, getPersistentCacheIndexManager } = firestoreModular;
const { getApp } = modular;
const app = getApp('secondaryFromNative');
Expand All @@ -759,6 +809,23 @@ describe('firestore()', function () {
should.equal(indexManager, null);
});
});

describe('macOS should throw exception when calling `persistentCacheIndexManager()`', function () {
it('should throw an exception', async function () {
if (!Platform.other) {
return;
}
const { getFirestore, getPersistentCacheIndexManager } = firestoreModular;

try {
const db = getFirestore();
getPersistentCacheIndexManager(db);
throw new Error('Did not throw an Error.');
} catch (e) {
e.message.should.containEql('not supported');
}
});
});
});
});
});

0 comments on commit c1d39fa

Please sign in to comment.