import { chain , Decoder , fields , fieldsAuto , number , string } from ".." ; test ( "adding extra fields to records" , ( ) => { type Product = { name : string ; price : number ; version : number ; } ; const data = { name : "Comfortable Bed" , price : 10e3 } ; const productDecoder1 = fields ( ( field ) : Product => ( { name : field ( "name" , string ) , price : field ( "price" , number ) , version : 1 , } ) ) ; expect ( productDecoder1 ( data ) ) . toMatchInlineSnapshot ( `
    Object {
      "name": "Comfortable Bed",
      "price": 10000,
      "version": 1,
    }
  ` ) ; const productDecoder2 = fieldsAuto < Product > ( { name : string , price : number , version : ( ) => 1 , } ) ; expect ( productDecoder2 ( data ) ) . toEqual ( productDecoder1 ( data ) ) ; const always = < T > ( value ) => ( ) : T => value ; const productDecoder3 = fieldsAuto < Product > ( { name : string , price : number , version : always ( 1 ) , } ) ; expect ( productDecoder3 ( data ) ) . toEqual ( productDecoder2 ( data ) ) ; const productDecoder4 = chain ( fieldsAuto ( { name : string , price : number , } ) , ( props ) => ( { ... props , version : 1 } ) ) ; expect ( productDecoder4 ( data ) ) . toEqual ( productDecoder3 ( data ) ) ; } ) ;