import { expect } from "chai" ; import { stubSaveableStore } from "./fakes.test" ; describe ( "SaveableStore" , ( ) => { describe ( "setValue" , ( ) => { it ( "sets the state on the store when given a new state" , ( ) => { const { store } = stubSaveableStore ( ) ; const newState = "def" ; store . setValue ( newState ) ; expect ( store . value ) . to . be . equal ( newState ) ; } ) ; it ( "saves the state when given a new state" , ( ) => { const { getInitialValue , saveValue , store } = stubSaveableStore ( ) ; const oldValue = getInitialValue ( ) ; const newValue = "def" ; store . setValue ( newValue ) ; expect ( saveValue ) . to . have . been . calledWithExactly ( newValue , oldValue ) ; } ) ; } ) ; describe ( "value" , ( ) => { it ( "sets the state on the store when given an initial state" , ( ) => { const { getInitialValue , store } = stubSaveableStore ( ) ; const actualInitialValue = store . value ; expect ( actualInitialValue ) . to . be . equal ( getInitialValue ( ) ) ; } ) ; } ) ; } ) ;