@@ -405,3 +405,47 @@ describe('View', () => {
405405 expect ( s ) . toMatchJson ( { id : 3 , loan : 3000 , name : 'Sander Hoogendoorn' } ) ;
406406 } ) ;
407407} ) ;
408+
409+ const toThing = view ( {
410+ id : 'id' ,
411+ name : 'name' ,
412+ } ) ;
413+
414+ const data = [
415+ { id : 1 , name : 'a' } ,
416+ { id : 2 , name : 'b' } ,
417+ { id : 3 , name : 'c' } ,
418+ ] ;
419+
420+ const options = { take : 3 } ;
421+
422+ describe ( 'view works' , ( ) => {
423+ test ( 'toThing works for an array' , ( ) => {
424+ const things = toThing . from ( data ) ;
425+ expect ( things ) . toHaveLength ( 3 ) ;
426+ expect ( ( things as any ) . options ) . toBeUndefined ( ) ;
427+ } ) ;
428+
429+ test ( 'toThing works for a List' , ( ) => {
430+ const pl = toList ( data ) ;
431+ const things = toThing . from ( pl ) ;
432+ expect ( things ) . toHaveLength ( 3 ) ;
433+ expect ( ( things as any ) . options ) . toBeUndefined ( ) ;
434+ } ) ;
435+
436+ test ( 'toThing works for a PageList' , ( ) => {
437+ const pl = toPageList ( data ) ;
438+ expect ( pl . options ) . toBeUndefined ( ) ;
439+ const things = toThing . from ( pl ) ;
440+ expect ( things ) . toHaveLength ( 3 ) ;
441+ expect ( things . options ) . toBeUndefined ( ) ;
442+ } ) ;
443+
444+ test ( 'toThing works for a PageList with options' , ( ) => {
445+ const pl = toPageList ( data , options ) ;
446+ expect ( pl . options ) . toEqual ( options ) ;
447+ const things = toThing . from ( pl ) ;
448+ expect ( things ) . toHaveLength ( 3 ) ;
449+ expect ( things . options ) . toEqual ( options ) ;
450+ } ) ;
451+ } ) ;
0 commit comments