Skip to content
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

fix: Removing FirebaseServiceInterface and FirebaseServiceInternalsInterface #1128

Merged
merged 3 commits into from
Jan 11, 2021
Merged
Changes from 1 commit
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
71 changes: 71 additions & 0 deletions test/unit/firebase-namespace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,13 @@ describe('FirebaseNamespace', () => {
it('should return a reference to Auth type', () => {
expect(firebaseNamespace.auth.Auth).to.be.deep.equal(AuthImpl);
});

it('should return a cached version of Auth on subsequent calls', () => {
firebaseNamespace.initializeApp(mocks.appOptions);
const serviceNamespace1: Auth = firebaseNamespace.auth();
const serviceNamespace2: Auth = firebaseNamespace.auth();
expect(serviceNamespace1).to.deep.equal(serviceNamespace2);
hiranya911 marked this conversation as resolved.
Show resolved Hide resolved
});
});

describe('#database()', () => {
Expand Down Expand Up @@ -406,6 +413,14 @@ describe('FirebaseNamespace', () => {
it('should return a reference to enableLogging function', () => {
expect(firebaseNamespace.database.enableLogging).to.be.deep.equal(enableLogging);
});

it('should return a cached version of Database on subsequent calls', () => {
const app = firebaseNamespace.initializeApp(mocks.appOptions);
const db1: Database = firebaseNamespace.database();
const db2: Database = firebaseNamespace.database();
expect(db1).to.deep.equal(db2);
return app.delete();
});
});

describe('#messaging()', () => {
Expand Down Expand Up @@ -437,6 +452,13 @@ describe('FirebaseNamespace', () => {
it('should return a reference to Messaging type', () => {
expect(firebaseNamespace.messaging.Messaging).to.be.deep.equal(MessagingImpl);
});

it('should return a cached version of Messaging on subsequent calls', () => {
firebaseNamespace.initializeApp(mocks.appOptions);
const serviceNamespace1: Messaging = firebaseNamespace.messaging();
const serviceNamespace2: Messaging = firebaseNamespace.messaging();
expect(serviceNamespace1).to.deep.equal(serviceNamespace2);
});
});

describe('#machine-learning()', () => {
Expand Down Expand Up @@ -469,6 +491,13 @@ describe('FirebaseNamespace', () => {
expect(firebaseNamespace.machineLearning.MachineLearning)
.to.be.deep.equal(MachineLearningImpl);
});

it('should return a cached version of MachineLearning on subsequent calls', () => {
firebaseNamespace.initializeApp(mocks.appOptions);
const service1: MachineLearning = firebaseNamespace.machineLearning();
const service2: MachineLearning = firebaseNamespace.machineLearning();
expect(service1).to.equal(service2);
});
});

describe('#storage()', () => {
Expand Down Expand Up @@ -500,6 +529,13 @@ describe('FirebaseNamespace', () => {
it('should return a reference to Storage type', () => {
expect(firebaseNamespace.storage.Storage).to.be.deep.equal(StorageImpl);
});

it('should return a cached version of Storage on subsequent calls', () => {
firebaseNamespace.initializeApp(mocks.appOptions);
const serviceNamespace1: Storage = firebaseNamespace.storage();
const serviceNamespace2: Storage = firebaseNamespace.storage();
expect(serviceNamespace1).to.deep.equal(serviceNamespace2);
});
});

describe('#firestore()', () => {
Expand Down Expand Up @@ -555,6 +591,13 @@ describe('FirebaseNamespace', () => {
it('should return a reference to the v1 namespace', () => {
expect(firebaseNamespace.firestore.v1).to.be.deep.equal(v1);
});

it('should return a cached version of Firestore on subsequent calls', () => {
firebaseNamespace.initializeApp(mocks.appOptions);
const service1: Firestore = firebaseNamespace.firestore();
const service2: Firestore = firebaseNamespace.firestore();
expect(service1).to.deep.equal(service2);
});
});

describe('#instanceId()', () => {
Expand Down Expand Up @@ -588,6 +631,13 @@ describe('FirebaseNamespace', () => {
it('should return a reference to InstanceId type', () => {
expect(firebaseNamespace.instanceId.InstanceId).to.be.deep.equal(InstanceIdImpl);
});

it('should return a cached version of InstanceId on subsequent calls', () => {
firebaseNamespace.initializeApp(mocks.appOptions);
const service1: InstanceId = firebaseNamespace.instanceId();
const service2: InstanceId = firebaseNamespace.instanceId();
expect(service1).to.equal(service2);
});
});

describe('#projectManagement()', () => {
Expand Down Expand Up @@ -622,6 +672,13 @@ describe('FirebaseNamespace', () => {
expect(firebaseNamespace.projectManagement.ProjectManagement)
.to.be.deep.equal(ProjectManagementImpl);
});

it('should return a cached version of ProjectManagement on subsequent calls', () => {
firebaseNamespace.initializeApp(mocks.appOptions);
const service1: ProjectManagement = firebaseNamespace.projectManagement();
const service2: ProjectManagement = firebaseNamespace.projectManagement();
expect(service1).to.equal(service2);
});
});

describe('#securityRules()', () => {
Expand Down Expand Up @@ -656,6 +713,13 @@ describe('FirebaseNamespace', () => {
expect(firebaseNamespace.securityRules.SecurityRules)
.to.be.deep.equal(SecurityRulesImpl);
});

it('should return a cached version of SecurityRules on subsequent calls', () => {
firebaseNamespace.initializeApp(mocks.appOptions);
const service1: SecurityRules = firebaseNamespace.securityRules();
const service2: SecurityRules = firebaseNamespace.securityRules();
expect(service1).to.equal(service2);
});
});

describe('#remoteConfig()', () => {
Expand Down Expand Up @@ -687,5 +751,12 @@ describe('FirebaseNamespace', () => {
it('should return a reference to RemoteConfig type', () => {
expect(firebaseNamespace.remoteConfig.RemoteConfig).to.be.deep.equal(RemoteConfigImpl);
});

it('should return a cached version of RemoteConfig on subsequent calls', () => {
firebaseNamespace.initializeApp(mocks.appOptions);
const service1: RemoteConfig = firebaseNamespace.remoteConfig();
const service2: RemoteConfig = firebaseNamespace.remoteConfig();
expect(service1).to.equal(service2);
});
});
});