@@ -21,20 +21,16 @@ import firebase from '../util/firebase_export';
21
21
import { apiDescribe , withTestDoc , withTestDb } from '../util/helpers' ;
22
22
import { EventsAccumulator } from '../util/events_accumulator' ;
23
23
24
- // TODO(array-features): Remove "as any"
25
- // tslint:disable-next-line:no-any variable-name Type alias can be capitalized.
26
- const FieldValue = firebase . firestore . FieldValue as any ;
24
+ // tslint:disable-next-line:variable-name Type alias can be capitalized.
25
+ const FieldValue = firebase . firestore . FieldValue ;
27
26
28
27
/**
29
28
* Note: Transforms are tested pretty thoroughly in server_timestamp.test.ts
30
29
* (via set, update, transactions, nested in documents, multiple transforms
31
30
* together, etc.) and so these tests mostly focus on the array transform
32
31
* semantics.
33
32
*/
34
- // TODO(array-features): Enable these tests once the feature is available in
35
- // prod. For now you can run these tests using:
36
- // yarn test:browser --integration --local
37
- apiDescribe . skip ( 'Array Transforms:' , persistence => {
33
+ apiDescribe ( 'Array Transforms:' , persistence => {
38
34
// A document reference to read and write to.
39
35
let docRef : firestore . DocumentReference ;
40
36
@@ -87,15 +83,15 @@ apiDescribe.skip('Array Transforms:', persistence => {
87
83
88
84
it ( 'create document with arrayUnion()' , async ( ) => {
89
85
await withTestSetup ( async ( ) => {
90
- await docRef . set ( { array : FieldValue . _arrayUnion ( 1 , 2 ) } ) ;
86
+ await docRef . set ( { array : FieldValue . arrayUnion ( 1 , 2 ) } ) ;
91
87
expectLocalAndRemoteEvent ( { array : [ 1 , 2 ] } ) ;
92
88
} ) ;
93
89
} ) ;
94
90
95
91
it ( 'append to array via update()' , async ( ) => {
96
92
await withTestSetup ( async ( ) => {
97
93
await writeInitialData ( { array : [ 1 , 3 ] } ) ;
98
- await docRef . update ( { array : FieldValue . _arrayUnion ( 2 , 1 , 4 ) } ) ;
94
+ await docRef . update ( { array : FieldValue . arrayUnion ( 2 , 1 , 4 ) } ) ;
99
95
await expectLocalAndRemoteEvent ( { array : [ 1 , 3 , 2 , 4 ] } ) ;
100
96
} ) ;
101
97
} ) ;
@@ -104,7 +100,7 @@ apiDescribe.skip('Array Transforms:', persistence => {
104
100
await withTestSetup ( async ( ) => {
105
101
await writeInitialData ( { array : [ 1 , 3 ] } ) ;
106
102
await docRef . set (
107
- { array : FieldValue . _arrayUnion ( 2 , 1 , 4 ) } ,
103
+ { array : FieldValue . arrayUnion ( 2 , 1 , 4 ) } ,
108
104
{ merge : true }
109
105
) ;
110
106
await expectLocalAndRemoteEvent ( { array : [ 1 , 3 , 2 , 4 ] } ) ;
@@ -115,7 +111,7 @@ apiDescribe.skip('Array Transforms:', persistence => {
115
111
await withTestSetup ( async ( ) => {
116
112
await writeInitialData ( { array : [ { a : 'hi' } ] } ) ;
117
113
await docRef . update ( {
118
- array : FieldValue . _arrayUnion ( { a : 'hi' } , { a : 'bye' } )
114
+ array : FieldValue . arrayUnion ( { a : 'hi' } , { a : 'bye' } )
119
115
} ) ;
120
116
await expectLocalAndRemoteEvent ( { array : [ { a : 'hi' } , { a : 'bye' } ] } ) ;
121
117
} ) ;
@@ -124,7 +120,7 @@ apiDescribe.skip('Array Transforms:', persistence => {
124
120
it ( 'remove from array via update()' , async ( ) => {
125
121
await withTestSetup ( async ( ) => {
126
122
await writeInitialData ( { array : [ 1 , 3 , 1 , 3 ] } ) ;
127
- await docRef . update ( { array : FieldValue . _arrayRemove ( 1 , 4 ) } ) ;
123
+ await docRef . update ( { array : FieldValue . arrayRemove ( 1 , 4 ) } ) ;
128
124
await expectLocalAndRemoteEvent ( { array : [ 3 , 3 ] } ) ;
129
125
} ) ;
130
126
} ) ;
@@ -133,7 +129,7 @@ apiDescribe.skip('Array Transforms:', persistence => {
133
129
await withTestSetup ( async ( ) => {
134
130
await writeInitialData ( { array : [ 1 , 3 , 1 , 3 ] } ) ;
135
131
await docRef . set (
136
- { array : FieldValue . _arrayRemove ( 1 , 4 ) } ,
132
+ { array : FieldValue . arrayRemove ( 1 , 4 ) } ,
137
133
{ merge : true }
138
134
) ;
139
135
await expectLocalAndRemoteEvent ( { array : [ 3 , 3 ] } ) ;
@@ -143,7 +139,7 @@ apiDescribe.skip('Array Transforms:', persistence => {
143
139
it ( 'remove object from array via update()' , async ( ) => {
144
140
await withTestSetup ( async ( ) => {
145
141
await writeInitialData ( { array : [ { a : 'hi' } , { a : 'bye' } ] } ) ;
146
- await docRef . update ( { array : FieldValue . _arrayRemove ( { a : 'hi' } ) } ) ;
142
+ await docRef . update ( { array : FieldValue . arrayRemove ( { a : 'hi' } ) } ) ;
147
143
await expectLocalAndRemoteEvent ( { array : [ { a : 'bye' } ] } ) ;
148
144
} ) ;
149
145
} ) ;
@@ -158,7 +154,7 @@ apiDescribe.skip('Array Transforms:', persistence => {
158
154
( persistence ? describe : describe . skip ) ( 'Server Application: ' , ( ) => {
159
155
it ( 'set() with no cached base doc' , async ( ) => {
160
156
await withTestDoc ( persistence , async docRef => {
161
- await docRef . set ( { array : FieldValue . _arrayUnion ( 1 , 2 ) } ) ;
157
+ await docRef . set ( { array : FieldValue . arrayUnion ( 1 , 2 ) } ) ;
162
158
const snapshot = await docRef . get ( { source : 'cache' } ) ;
163
159
expect ( snapshot . data ( ) ) . to . deep . equal ( { array : [ 1 , 2 ] } ) ;
164
160
} ) ;
@@ -175,7 +171,7 @@ apiDescribe.skip('Array Transforms:', persistence => {
175
171
176
172
await withTestDb ( persistence , async db => {
177
173
const docRef = db . doc ( path ) ;
178
- await docRef . update ( { array : FieldValue . _arrayUnion ( 1 , 2 ) } ) ;
174
+ await docRef . update ( { array : FieldValue . arrayUnion ( 1 , 2 ) } ) ;
179
175
180
176
// Nothing should be cached since it was an update and we had no base
181
177
// doc.
@@ -202,7 +198,7 @@ apiDescribe.skip('Array Transforms:', persistence => {
202
198
await withTestDb ( persistence , async db => {
203
199
const docRef = db . doc ( path ) ;
204
200
await docRef . set (
205
- { array : FieldValue . _arrayUnion ( 1 , 2 ) } ,
201
+ { array : FieldValue . arrayUnion ( 1 , 2 ) } ,
206
202
{ merge : true }
207
203
) ;
208
204
@@ -215,7 +211,7 @@ apiDescribe.skip('Array Transforms:', persistence => {
215
211
it ( 'update() with cached base doc using arrayUnion()' , async ( ) => {
216
212
await withTestDoc ( persistence , async docRef => {
217
213
await docRef . set ( { array : [ 42 ] } ) ;
218
- await docRef . update ( { array : FieldValue . _arrayUnion ( 1 , 2 ) } ) ;
214
+ await docRef . update ( { array : FieldValue . arrayUnion ( 1 , 2 ) } ) ;
219
215
const snapshot = await docRef . get ( { source : 'cache' } ) ;
220
216
expect ( snapshot . data ( ) ) . to . deep . equal ( { array : [ 42 , 1 , 2 ] } ) ;
221
217
} ) ;
@@ -224,7 +220,7 @@ apiDescribe.skip('Array Transforms:', persistence => {
224
220
it ( 'update() with cached base doc using arrayRemove()' , async ( ) => {
225
221
await withTestDoc ( persistence , async docRef => {
226
222
await docRef . set ( { array : [ 42 , 1 , 2 ] } ) ;
227
- await docRef . update ( { array : FieldValue . _arrayRemove ( 1 , 2 ) } ) ;
223
+ await docRef . update ( { array : FieldValue . arrayRemove ( 1 , 2 ) } ) ;
228
224
const snapshot = await docRef . get ( { source : 'cache' } ) ;
229
225
expect ( snapshot . data ( ) ) . to . deep . equal ( { array : [ 42 ] } ) ;
230
226
} ) ;
0 commit comments