@@ -19,15 +19,17 @@ import { expect } from 'chai';
19
19
import { SinonStub , stub } from 'sinon' ;
20
20
import * as deleteInstallationRequestModule from '../functions/delete-installation-request' ;
21
21
import { get , set } from '../helpers/idb-manager' ;
22
- import { AppConfig } from '../interfaces/app-config' ;
23
- import { FirebaseDependencies } from '../interfaces/firebase-dependencies' ;
22
+ import {
23
+ FirebaseInstallations ,
24
+ AppConfig
25
+ } from '@firebase/installations-types-exp' ;
24
26
import {
25
27
InProgressInstallationEntry ,
26
28
RegisteredInstallationEntry ,
27
29
RequestStatus ,
28
30
UnregisteredInstallationEntry
29
31
} from '../interfaces/installation-entry' ;
30
- import { getFakeDependencies } from '../testing/fake-generators' ;
32
+ import { getFakeInstallations } from '../testing/fake-generators' ;
31
33
import '../testing/setup' ;
32
34
import { ErrorCode } from '../util/errors' ;
33
35
import { sleep } from '../util/sleep' ;
@@ -36,14 +38,14 @@ import { deleteInstallation } from './delete-installation';
36
38
const FID = 'children-of-the-damned' ;
37
39
38
40
describe ( 'deleteInstallation' , ( ) => {
39
- let dependencies : FirebaseDependencies ;
41
+ let installations : FirebaseInstallations ;
40
42
let deleteInstallationRequestSpy : SinonStub <
41
43
[ AppConfig , RegisteredInstallationEntry ] ,
42
44
Promise < void >
43
45
> ;
44
46
45
47
beforeEach ( ( ) => {
46
- dependencies = getFakeDependencies ( ) ;
48
+ installations = getFakeInstallations ( ) ;
47
49
48
50
deleteInstallationRequestSpy = stub (
49
51
deleteInstallationRequestModule ,
@@ -54,7 +56,7 @@ describe('deleteInstallation', () => {
54
56
} ) ;
55
57
56
58
it ( 'resolves without calling server API if there is no installation' , async ( ) => {
57
- await expect ( deleteInstallation ( dependencies ) ) . to . be . fulfilled ;
59
+ await expect ( deleteInstallation ( installations ) ) . to . be . fulfilled ;
58
60
expect ( deleteInstallationRequestSpy ) . not . to . have . been . called ;
59
61
} ) ;
60
62
@@ -63,11 +65,11 @@ describe('deleteInstallation', () => {
63
65
registrationStatus : RequestStatus . NOT_STARTED ,
64
66
fid : FID
65
67
} ;
66
- await set ( dependencies . appConfig , entry ) ;
68
+ await set ( installations . appConfig , entry ) ;
67
69
68
- await expect ( deleteInstallation ( dependencies ) ) . to . be . fulfilled ;
70
+ await expect ( deleteInstallation ( installations ) ) . to . be . fulfilled ;
69
71
expect ( deleteInstallationRequestSpy ) . not . to . have . been . called ;
70
- await expect ( get ( dependencies . appConfig ) ) . to . eventually . be . undefined ;
72
+ await expect ( get ( installations . appConfig ) ) . to . eventually . be . undefined ;
71
73
} ) ;
72
74
73
75
it ( 'rejects without calling server API if the installation is pending' , async ( ) => {
@@ -76,9 +78,9 @@ describe('deleteInstallation', () => {
76
78
registrationStatus : RequestStatus . IN_PROGRESS ,
77
79
registrationTime : Date . now ( ) - 3 * 1000
78
80
} ;
79
- await set ( dependencies . appConfig , entry ) ;
81
+ await set ( installations . appConfig , entry ) ;
80
82
81
- await expect ( deleteInstallation ( dependencies ) ) . to . be . rejectedWith (
83
+ await expect ( deleteInstallation ( installations ) ) . to . be . rejectedWith (
82
84
ErrorCode . DELETE_PENDING_REGISTRATION
83
85
) ;
84
86
expect ( deleteInstallationRequestSpy ) . not . to . have . been . called ;
@@ -96,10 +98,10 @@ describe('deleteInstallation', () => {
96
98
creationTime : Date . now ( )
97
99
}
98
100
} ;
99
- await set ( dependencies . appConfig , entry ) ;
101
+ await set ( installations . appConfig , entry ) ;
100
102
stub ( navigator , 'onLine' ) . value ( false ) ;
101
103
102
- await expect ( deleteInstallation ( dependencies ) ) . to . be . rejectedWith (
104
+ await expect ( deleteInstallation ( installations ) ) . to . be . rejectedWith (
103
105
ErrorCode . APP_OFFLINE
104
106
) ;
105
107
expect ( deleteInstallationRequestSpy ) . not . to . have . been . called ;
@@ -117,13 +119,13 @@ describe('deleteInstallation', () => {
117
119
creationTime : Date . now ( )
118
120
}
119
121
} ;
120
- await set ( dependencies . appConfig , entry ) ;
122
+ await set ( installations . appConfig , entry ) ;
121
123
122
- await expect ( deleteInstallation ( dependencies ) ) . to . be . fulfilled ;
124
+ await expect ( deleteInstallation ( installations ) ) . to . be . fulfilled ;
123
125
expect ( deleteInstallationRequestSpy ) . to . have . been . calledOnceWith (
124
- dependencies . appConfig ,
126
+ installations . appConfig ,
125
127
entry
126
128
) ;
127
- await expect ( get ( dependencies . appConfig ) ) . to . eventually . be . undefined ;
129
+ await expect ( get ( installations . appConfig ) ) . to . eventually . be . undefined ;
128
130
} ) ;
129
131
} ) ;
0 commit comments