@@ -105,6 +105,21 @@ describe('MachineLearning', () => {
105105 } ;
106106 const MODEL2 = new Model ( MODEL_RESPONSE2 ) ;
107107
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+
108123 const STATUS_ERROR_RESPONSE : {
109124 code : number ;
110125 message : string ;
@@ -245,8 +260,25 @@ describe('MachineLearning', () => {
245260 'gs://test-project-bucket/Firebase/ML/Models/model1.tflite' ) ;
246261 expect ( tflite . sizeBytes ) . to . be . equal ( 16900988 ) ;
247262 } ) ;
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+
248278 } ) ;
249279
280+
281+
250282 describe ( 'getModel' , ( ) => {
251283 it ( 'should propagate API errors' , ( ) => {
252284 const stub = sinon
0 commit comments