const { Action, Page } = require('~')
const Store = require('../')
const td = require('testdouble')
const domain = require('../../domain')

const documentObject = {
  title: 'Some Company\'s Journal 2017',
  start: '2017-01-01',
  end: '2017-12-31',
  currencyCode: domain.Currency.USD.code,
  commaPeriodSetting: 'comma-period'
}
/**
 * Creates a store for testing
 */
const createStore = async () => {
  localStorage.clear()

  const store = new Store()

  const save = store.save
  const saved = new Promise(resolve => {
    store.save = function () {
      resolve()
      return save.apply(this, arguments)
    }
  })
  store.installDefaultModules()
  store.dispatch({ type: Action.HUB_READY })

  td.replace($, 'getScript')
  td.when($.getScript(td.matchers.anything())).thenResolve()

  await saved

  store.location = {
    reload: td.func(),
    replace: td.func(),
    pathname: Page.APP_SETTINGS
  }

  return store
}

module.exports.createStore = createStore
module.exports.documentObject = documentObject

@@ -454,34 +454,8 @@
 ()%0A%0A
-  const save = store.save%0A
   co
@@ -493,108 +493,46 @@
  =%3E 
-%7B%0A    store.save = function () %7B%0A      resolve()%0A      return save.apply(this, arguments)%0A    %7D%0A  %7D)
+store.on(Action.MODEL_SAVE, resolve))%0A
 %0A  s
@@ -560,16 +560,17 @@
 dules()%0A
+%0A
   store.

refactor test helper