@@ -5,6 +5,7 @@ import * as classWithAdditional from './test-class-with-additional-props';
55import { Type } from '../src/reflection-type' ;
66import { serialize } from '../src/serialize' ;
77import { getType , withType } from '../src/type-tag' ;
8+ import { File , FormBinary } from '../src/make' ;
89
910describe ( 'union differentation' , ( ) => {
1011 it ( 'handles cases where union children are missing the tag' , ( ) => {
@@ -408,6 +409,30 @@ describe('unknown', () => {
408409 expect ( fun ( item ) . success ( ) ) . toEqual ( item ) ;
409410 expect ( fun ( item ) . success ( ) !== item ) . toBeTruthy ( ) ;
410411 } ) ;
412+ it ( 'keeps Buffer instances' , async ( ) => {
413+ const fun = make . fromReflection ( { type : 'unknown' } ) ;
414+ const item = Buffer . alloc ( 1 , 'x' , 'utf-8' ) ;
415+ expect ( fun ( item ) . success ( ) ) . toEqual ( item ) ;
416+ expect ( fun ( item ) . success ( ) === item ) . toBeTruthy ( ) ;
417+ } ) ;
418+ it ( 'keeps File instances' , async ( ) => {
419+ const fun = make . fromReflection ( { type : 'unknown' } ) ;
420+ const item = new File ( 'path' , 10 , 'name' ) ;
421+ expect ( fun ( item ) . success ( ) ) . toEqual ( item ) ;
422+ expect ( fun ( item ) . success ( ) === item ) . toBeTruthy ( ) ;
423+ } ) ;
424+ it ( 'keeps FormBinary instances' , async ( ) => {
425+ const fun = make . fromReflection ( { type : 'unknown' } ) ;
426+ const item = new FormBinary ( { binary : Buffer . alloc ( 1 , 'x' , 'utf-8' ) } ) ;
427+ expect ( fun ( item ) . success ( ) ) . toEqual ( item ) ;
428+ expect ( fun ( item ) . success ( ) === item ) . toBeTruthy ( ) ;
429+ } ) ;
430+ it ( 'keeps FormBinary instances' , async ( ) => {
431+ const fun = make . fromReflection ( { type : 'unknown' } ) ;
432+ const item = new FormBinary ( { binary : Buffer . alloc ( 1 , 'x' , 'utf-8' ) } ) ;
433+ expect ( fun ( item ) . success ( ) ) . toEqual ( item ) ;
434+ expect ( fun ( item ) . success ( ) === item ) . toBeTruthy ( ) ;
435+ } ) ;
411436 it ( 'keeps custom instances' , async ( ) => {
412437 const fun = make . fromReflection ( { type : 'unknown' } ) ;
413438 const item = new SomeClass ( ) ;
0 commit comments