import { deepFreeze } from './deep_freeze' ; it ( 'returns the first argument with all original references' , ( ) => { const a = { } ; const b = { } ; const c = { a , b } ; const frozen = deepFreeze ( c ) ; expect ( frozen ) . toBe ( c ) ; expect ( frozen . a ) . toBe ( a ) ; expect ( frozen . b ) . toBe ( b ) ; } ) ; it ( 'prevents adding properties to argument' , ( ) => { const frozen = deepFreeze ( { } ) ; expect ( ( ) => { frozen . foo = true ; } ) . toThrowError ( `object is not extensible` ) ; } ) ; it ( 'prevents changing properties on argument' , ( ) => { const frozen = deepFreeze ( { foo : false } ) ; expect ( ( ) => { frozen . foo = true ; } ) . toThrowError ( `read only property 'foo'` ) ; } ) ; it ( 'prevents changing properties on nested children of argument' , ( ) => { const frozen = deepFreeze ( { foo : { bar : { baz : { box : 1 } } } } ) ; expect ( ( ) => { frozen . foo . bar . baz . box = 2 ; } ) . toThrowError ( `read only property 'box'` ) ; } ) ; it ( 'prevents adding items to a frozen array' , ( ) => { const frozen = deepFreeze ( { foo : [ 1 ] } ) ; expect ( ( ) => { frozen . foo . push ( 2 ) ; } ) . toThrowError ( `object is not extensible` ) ; } ) ; it ( 'prevents reassigning items in a frozen array' , ( ) => { const frozen = deepFreeze ( { foo : [ 1 ] } ) ; expect ( ( ) => { frozen . foo [ 0 ] = 2 ; } ) . toThrowError ( `read only property '0'` ) ; } ) ;