@@ -19,13 +19,13 @@ import { FirebaseError } from '@firebase/util';
1919import { expect } from 'chai' ;
2020import { SinonStub , stub } from 'sinon' ;
2121import { CreateInstallationResponse } from '../interfaces/api-response' ;
22- import { AppConfig } from '../interfaces/installation-impl' ;
22+ import { FirebaseInstallationsImpl } from '../interfaces/installation-impl' ;
2323import {
2424 InProgressInstallationEntry ,
2525 RequestStatus
2626} from '../interfaces/installation-entry' ;
2727import { compareHeaders } from '../testing/compare-headers' ;
28- import { getFakeAppConfig } from '../testing/fake-generators' ;
28+ import { getFakeInstallations } from '../testing/fake-generators' ;
2929import '../testing/setup' ;
3030import {
3131 INSTALLATIONS_API_URL ,
@@ -38,13 +38,13 @@ import { createInstallationRequest } from './create-installation-request';
3838const FID = 'defenders-of-the-faith' ;
3939
4040describe ( 'createInstallationRequest' , ( ) => {
41- let appConfig : AppConfig ;
41+ let fakeInstallations : FirebaseInstallationsImpl ;
4242 let fetchSpy : SinonStub < [ RequestInfo , RequestInit ?] , Promise < Response > > ;
4343 let inProgressInstallationEntry : InProgressInstallationEntry ;
4444 let response : CreateInstallationResponse ;
4545
4646 beforeEach ( ( ) => {
47- appConfig = getFakeAppConfig ( ) ;
47+ fakeInstallations = getFakeInstallations ( ) ;
4848
4949 inProgressInstallationEntry = {
5050 fid : FID ,
@@ -71,7 +71,7 @@ describe('createInstallationRequest', () => {
7171
7272 it ( 'registers a pending InstallationEntry' , async ( ) => {
7373 const registeredInstallationEntry = await createInstallationRequest (
74- appConfig ,
74+ fakeInstallations ,
7575 inProgressInstallationEntry
7676 ) ;
7777 expect ( registeredInstallationEntry . registrationStatus ) . to . equal (
@@ -83,12 +83,13 @@ describe('createInstallationRequest', () => {
8383 const expectedHeaders = new Headers ( {
8484 'Content-Type' : 'application/json' ,
8585 Accept : 'application/json' ,
86- 'x-goog-api-key' : 'apiKey'
86+ 'x-goog-api-key' : 'apiKey' ,
87+ 'x-firebase-client' : 'a/1.2.3 b/2.3.4'
8788 } ) ;
8889 const expectedBody = {
8990 fid : FID ,
9091 authVersion : INTERNAL_AUTH_VERSION ,
91- appId : appConfig . appId ,
92+ appId : fakeInstallations . appConfig . appId ,
9293 sdkVersion : PACKAGE_VERSION
9394 } ;
9495 const expectedRequest : RequestInit = {
@@ -98,7 +99,10 @@ describe('createInstallationRequest', () => {
9899 } ;
99100 const expectedEndpoint = `${ INSTALLATIONS_API_URL } /projects/projectId/installations` ;
100101
101- await createInstallationRequest ( appConfig , inProgressInstallationEntry ) ;
102+ await createInstallationRequest (
103+ fakeInstallations ,
104+ inProgressInstallationEntry
105+ ) ;
102106 expect ( fetchSpy ) . to . be . calledOnceWith ( expectedEndpoint , expectedRequest ) ;
103107 const actualHeaders = fetchSpy . lastCall . lastArg . headers ;
104108 compareHeaders ( expectedHeaders , actualHeaders ) ;
@@ -117,7 +121,7 @@ describe('createInstallationRequest', () => {
117121 fetchSpy . resolves ( new Response ( JSON . stringify ( response ) ) ) ;
118122
119123 const registeredInstallationEntry = await createInstallationRequest (
120- appConfig ,
124+ fakeInstallations ,
121125 inProgressInstallationEntry
122126 ) ;
123127 expect ( registeredInstallationEntry . fid ) . to . equal ( FID ) ;
@@ -138,7 +142,10 @@ describe('createInstallationRequest', () => {
138142 ) ;
139143
140144 await expect (
141- createInstallationRequest ( appConfig , inProgressInstallationEntry )
145+ createInstallationRequest (
146+ fakeInstallations ,
147+ inProgressInstallationEntry
148+ )
142149 ) . to . be . rejectedWith ( FirebaseError ) ;
143150 } ) ;
144151
@@ -157,7 +164,10 @@ describe('createInstallationRequest', () => {
157164 fetchSpy . onCall ( 1 ) . resolves ( new Response ( JSON . stringify ( response ) ) ) ;
158165
159166 await expect (
160- createInstallationRequest ( appConfig , inProgressInstallationEntry )
167+ createInstallationRequest (
168+ fakeInstallations ,
169+ inProgressInstallationEntry
170+ )
161171 ) . to . be . fulfilled ;
162172 expect ( fetchSpy ) . to . be . calledTwice ;
163173 } ) ;
0 commit comments