@@ -105,6 +105,21 @@ describe('MachineLearning', () => {
105
105
} ;
106
106
const MODEL2 = new Model ( MODEL_RESPONSE2 ) ;
107
107
108
+ const MODEL_RESPONSE3 : any = {
109
+ name : 'projects/test-project/models/3456789' ,
110
+ createTime : '2020-02-07T23:45:23.288047Z' ,
111
+ updateTime : '2020-02-08T23:45:23.288047Z' ,
112
+ etag : 'etag345' ,
113
+ modelHash : 'modelHash345' ,
114
+ displayName : 'model_3' ,
115
+ tags : [ 'tag_3' , 'tag_4' ] ,
116
+ state : { published : true } ,
117
+ tfliteModel : {
118
+ managedUpload : true ,
119
+ sizeBytes : 22200222 ,
120
+ } ,
121
+ } ;
122
+
108
123
const STATUS_ERROR_RESPONSE : {
109
124
code : number ;
110
125
message : string ;
@@ -245,8 +260,25 @@ describe('MachineLearning', () => {
245
260
'gs://test-project-bucket/Firebase/ML/Models/model1.tflite' ) ;
246
261
expect ( tflite . sizeBytes ) . to . be . equal ( 16900988 ) ;
247
262
} ) ;
263
+
264
+ it ( 'should accept unknown fields gracefully' , ( ) => {
265
+ const model = new Model ( MODEL_RESPONSE3 ) ;
266
+ expect ( model . modelId ) . to . equal ( '3456789' ) ;
267
+ expect ( model . displayName ) . to . equal ( 'model_3' ) ;
268
+ expect ( model . tags ) . to . deep . equal ( [ 'tag_3' , 'tag_4' ] ) ;
269
+ expect ( model . createTime ) . to . equal ( CREATE_TIME_UTC ) ;
270
+ expect ( model . updateTime ) . to . equal ( UPDATE_TIME_UTC ) ;
271
+ expect ( model . validationError ) . to . be . undefined ;
272
+ expect ( model . published ) . to . be . true ;
273
+ expect ( model . etag ) . to . equal ( 'etag345' ) ;
274
+ expect ( model . modelHash ) . to . equal ( 'modelHash345' ) ;
275
+ expect ( model . tfliteModel ) . to . be . undefined ;
276
+ } ) ;
277
+
248
278
} ) ;
249
279
280
+
281
+
250
282
describe ( 'getModel' , ( ) => {
251
283
it ( 'should propagate API errors' , ( ) => {
252
284
const stub = sinon
0 commit comments