import { expect } from "chai" ; import { FlagSwappr } from "./FlagSwappr" ; const [ first , second , value ] = [ "first" , "second" , "value" ] ; describe ( "FlagSwappr" , ( ) => { it ( "gets a feature setting from a first generation" , ( ) : void => { const flagSwapper = new FlagSwappr < { value : string ; } > ( { generations : { [ first ] : { value } , } , } ) ; const currentValue = flagSwapper . flags . value ; expect ( currentValue ) . to . be . equal ( value ) ; } ) ; it ( "gets a feature setting from a second generation" , ( ) : void => { const flagSwapper = new FlagSwappr < { value : string ; } > ( { generation : second , generations : { [ first ] : { } , [ second ] : { value } , } , } ) ; const currentValue = flagSwapper . flags . value ; expect ( currentValue ) . to . be . equal ( value ) ; } ) ; it ( "gets an overridden feature setting from a second generation" , ( ) : void => { const flagSwapper = new FlagSwappr < { value : string ; } > ( { generation : second , generations : { [ first ] : { [ value ] : "wrong" , } , [ second ] : { value } , } , } ) ; const currentValue = flagSwapper . flags . value ; expect ( currentValue ) . to . be . equal ( value ) ; } ) ; it ( "gets an first feature setting from resetting to a first generation" , ( ) : void => { const flagSwapper = new FlagSwappr < { value : string ; } > ( { generation : second , generations : { [ first ] : { value : first , } , [ second ] : { value : second , } , } , } ) ; flagSwapper . setGeneration ( first ) ; const currentValue = flagSwapper . flags . value ; expect ( currentValue ) . to . be . equal ( first ) ; } ) ; it ( "gets a second feature setting from resetting to a second generation" , ( ) : void => { const flagSwapper = new FlagSwappr < { value : string ; } > ( { generation : first , generations : { [ first ] : { value : first , } , [ second ] : { value : second , } , } , } ) ; flagSwapper . setGeneration ( second ) ; const currentValue = flagSwapper . flags . value ; expect ( currentValue ) . to . be . equal ( second ) ; } ) ; } ) ;