import { chance } from "_/helpers" ; describe ( "Viewport" , ( ) => { const context = window . parent . document . getElementById ( "context" ) ! ; describe ( "#set" , ( ) => { afterEach ( ( ) => { viewport . reset ( ) ; } ) ; it ( "should set width" , ( ) => { const width = chance . integer ( { min : 100 , max : 400 } ) ; viewport . set ( width ) ; expect ( context . style . width ) . toEqual ( `${ width }px` ) ; expect ( context . style . height ) . toEqual ( "" ) ; } ) ; it ( "should set width and height" , ( ) => { const width = chance . integer ( { min : 100 , max : 400 } ) ; const height = chance . integer ( { min : 100 , max : 400 } ) ; viewport . set ( width , height ) ; expect ( context . style . width ) . toEqual ( `${ width }px` ) ; expect ( context . style . height ) . toEqual ( `${ height }px` ) ; } ) ; it ( "should set width and height of breakpoint" , ( ) => { viewport . set ( "tablet" ) ; expect ( context . style . width ) . toEqual ( `${ viewport . config . breakpoints [ 1 ] . size . width }px` ) ; expect ( context . style . height ) . toEqual ( `${ viewport . config . breakpoints [ 1 ] . size . height }px` ) ; } ) ; } ) ; describe ( "#reset" , ( ) => { it ( "should reset width and height" , ( ) => { const width = chance . integer ( { min : 100 , max : 400 } ) ; const height = chance . integer ( { min : 100 , max : 400 } ) ; viewport . set ( width , height ) ; viewport . reset ( ) ; expect ( context . style . width ) . toEqual ( "" ) ; expect ( context . style . height ) . toEqual ( "" ) ; } ) ; } ) ; } ) ;