import { expect } from "chai" ; import { getAbsoluteSizeInContainer , getAbsoluteSizeRemaining , AbsoluteSizeSchema , RelativeSizeSchema , } from "./Sizing" ; describe ( "getAbsoluteSizeRemaining" , ( ) => { it ( "subtracts height from the container height" , ( ) => { const container = { height : 490 , width : 350 , } ; const height = 210 ; const absoluteSize = getAbsoluteSizeRemaining ( container , height ) ; expect ( absoluteSize ) . to . be . deep . equal ( { height : 280 , width : 350 , } ) ; } ) ; } ) ; describe ( "getAbsoluteSizeInContainer" , ( ) => { it ( "keeps pixel sizes the same when given pixel sizes" , ( ) => { const container = { height : 490 , width : 350 , } ; const requestedSize = { height : 350 , width : 490 , } ; const absoluteSize = getAbsoluteSizeInContainer ( container , requestedSize ) ; expect ( absoluteSize ) . to . be . deep . equal ( requestedSize ) ; } ) ; it ( "calculates percentages when given percentage strings" , ( ) => { const container = { height : 490 , width : 350 , } ; const requestedSize = { height : "50%" , width : "100%" , } ; const absoluteSize = getAbsoluteSizeInContainer ( container , requestedSize ) ; expect ( absoluteSize ) . to . be . deep . equal ( { height : 245 , width : 350 , } ) ; } ) ; it ( "throws an error for an invalid percentage string" , ( ) => { const container = { height : 490 , width : 350 , } ; const requestedSize = { height : "50%" , width : "invalid%" , } ; const action = ( ) => { getAbsoluteSizeInContainer ( container , requestedSize ) ; } ; expect ( action ) . to . throw ( "Relative size should be in percentage form." ) ; } ) ; } ) ;