1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
1
18
import { expect } from 'chai' ;
2
19
import '../test/setup' ;
3
20
import { match , stub } from 'sinon' ;
4
- import { readHeartbeatsFromIndexedDB , writeHeartbeatsToIndexedDB } from './indexeddb' ;
21
+ import {
22
+ readHeartbeatsFromIndexedDB ,
23
+ writeHeartbeatsToIndexedDB
24
+ } from './indexeddb' ;
5
25
import { FirebaseApp } from './public-types' ;
6
26
import { AppError } from './errors' ;
7
27
import { HeartbeatsInIndexedDB } from './types' ;
@@ -20,15 +40,13 @@ describe('IndexedDB functions', () => {
20
40
await readHeartbeatsFromIndexedDB ( {
21
41
name : 'testname' ,
22
42
options : { appId : 'test-app-id' }
23
- } as FirebaseApp
24
- ) ;
43
+ } as FirebaseApp ) ;
25
44
expect ( warnStub ) . to . be . calledWith ( match . any , match ( AppError . IDB_GET ) ) ;
26
45
} else {
27
46
await readHeartbeatsFromIndexedDB ( {
28
47
name : 'testname' ,
29
48
options : { appId : 'test-app-id' }
30
- } as FirebaseApp
31
- ) ;
49
+ } as FirebaseApp ) ;
32
50
expect ( warnStub ) . to . be . calledWith ( match . any , match ( AppError . IDB_GET ) ) ;
33
51
}
34
52
} ) ;
@@ -37,21 +55,23 @@ describe('IndexedDB functions', () => {
37
55
if ( typeof window !== 'undefined' ) {
38
56
// Ensure that indexedDB.open() fails in browser. It will always fail in Node.
39
57
stub ( window . indexedDB , 'open' ) . throws ( new Error ( 'abcd' ) ) ;
40
- await writeHeartbeatsToIndexedDB ( {
41
- name : 'testname' ,
42
- options : { appId : 'test-app-id' }
43
- } as FirebaseApp ,
58
+ await writeHeartbeatsToIndexedDB (
59
+ {
60
+ name : 'testname' ,
61
+ options : { appId : 'test-app-id' }
62
+ } as FirebaseApp ,
44
63
{ } as HeartbeatsInIndexedDB
45
64
) ;
46
65
expect ( warnStub ) . to . be . calledWith ( match . any , match ( AppError . IDB_WRITE ) ) ;
47
66
} else {
48
- await writeHeartbeatsToIndexedDB ( {
49
- name : 'testname' ,
50
- options : { appId : 'test-app-id' }
51
- } as FirebaseApp ,
67
+ await writeHeartbeatsToIndexedDB (
68
+ {
69
+ name : 'testname' ,
70
+ options : { appId : 'test-app-id' }
71
+ } as FirebaseApp ,
52
72
{ } as HeartbeatsInIndexedDB
53
73
) ;
54
74
expect ( warnStub ) . to . be . calledWith ( match . any , match ( AppError . IDB_WRITE ) ) ;
55
75
}
56
76
} ) ;
57
- } ) ;
77
+ } ) ;
0 commit comments