14
14
* limitations under the License.
15
15
*/
16
16
17
- import { expect } from 'chai' ;
18
17
const duplexify = require ( 'duplexify' ) ;
19
18
20
- import * as is from 'is ' ;
19
+ import { expect } from 'chai ' ;
21
20
import * as path from 'path' ;
22
21
import * as protobufjs from 'protobufjs' ;
23
22
import * as through2 from 'through2' ;
24
-
25
23
import * as proto from '../protos/firestore_proto_api' ;
26
- import api = proto . google . firestore . v1 ;
27
24
28
25
import * as Firestore from '../src' ;
29
-
26
+ import { documentFromJson } from '../src/convert' ;
27
+ import { DocumentChangeType } from '../src/document-change' ;
30
28
import { ResourcePath } from '../src/path' ;
31
- import * as convert from '../src/convert' ;
32
-
29
+ import { isObject } from '../src/util' ;
33
30
import { createInstance as createInstanceHelper } from '../test/util/helpers' ;
34
- import { AnyDuringMigration } from '../src/types' ;
35
- import { DocumentChangeType } from '../src/document-change' ;
31
+
32
+ import api = proto . google . firestore . v1 ;
36
33
37
34
const REQUEST_TIME = 'REQUEST_TIME' ;
38
35
@@ -93,9 +90,9 @@ const convertInput = {
93
90
argument : json => {
94
91
const obj = JSON . parse ( json ) ;
95
92
function convertValue ( value ) {
96
- if ( is . object ( value ) ) {
93
+ if ( isObject ( value ) ) {
97
94
return convertObject ( value ) ;
98
- } else if ( is . array ( value ) ) {
95
+ } else if ( Array . isArray ( value ) ) {
99
96
return convertArray ( value ) ;
100
97
} else if ( value === 'NaN' ) {
101
98
return NaN ;
@@ -175,15 +172,15 @@ const convertInput = {
175
172
176
173
for ( const doc of snapshot . docs ) {
177
174
const deepCopy = JSON . parse ( JSON . stringify ( doc ) ) ;
178
- deepCopy . fields = convert . documentFromJson ( deepCopy . fields ) ;
175
+ deepCopy . fields = documentFromJson ( deepCopy . fields ) ;
179
176
docs . push (
180
177
firestore . snapshot_ ( deepCopy , readTime , 'json' ) as
181
178
Firestore . QueryDocumentSnapshot ) ;
182
179
}
183
180
184
181
for ( const change of snapshot . changes ) {
185
182
const deepCopy = JSON . parse ( JSON . stringify ( change . doc ) ) ;
186
- deepCopy . fields = convert . documentFromJson ( deepCopy . fields ) ;
183
+ deepCopy . fields = documentFromJson ( deepCopy . fields ) ;
187
184
const doc = firestore . snapshot_ ( deepCopy , readTime , 'json' ) ;
188
185
const type =
189
186
( [ 'unspecified' , 'added' , 'removed' , 'modified' ] [ change . kind ] as
@@ -208,7 +205,7 @@ const convertProto = {
208
205
}
209
206
if ( deepCopy . documentChange ) {
210
207
deepCopy . documentChange . document . fields =
211
- convert . documentFromJson ( deepCopy . documentChange . document . fields ) ;
208
+ documentFromJson ( deepCopy . documentChange . document . fields ) ;
212
209
}
213
210
return deepCopy ;
214
211
} ,
@@ -351,7 +348,8 @@ function runTest(spec) {
351
348
const setTest = spec => {
352
349
const overrides = { commit : commitHandler ( spec ) } ;
353
350
return createInstance ( overrides ) . then ( ( ) => {
354
- const setOption : AnyDuringMigration = { } ;
351
+ const setOption : { merge ?: boolean ,
352
+ mergeFields ?: Firestore . FieldPath [ ] } = { } ;
355
353
if ( spec . option && spec . option . all ) {
356
354
setOption . merge = true ;
357
355
} else if ( spec . option && spec . option . fields ) {
@@ -472,6 +470,7 @@ describe('Conformance Tests', () => {
472
470
const binaryProtoData =
473
471
require ( 'fs' ) . readFileSync ( path . join ( __dirname , 'test-suite.binproto' ) ) ;
474
472
473
+ // We don't have type information for the conformance proto.
475
474
// tslint:disable-next-line:no-any
476
475
const testSuite : any = TEST_SUITE_TYPE . decode ( binaryProtoData ) ;
477
476
0 commit comments