import { load, save } from './store';
const store = require('./store');

interface IStoreMock extends IMock {
  original: {
    load: typeof load;
    save: typeof save;
  };
  mock: {
    load: (mock: typeof load) => void;
    save: (mock: typeof save) => void;
  };
  restore: () => void;
}

export const storeMock: IStoreMock = {
  original: {
    load: store.load,
    save: store.save,
  },
  mock: {
    load(mock) {
      store.load = mock;
    },
    save(mock) {
      store.save = mock;
    },
  },
  restore() {
    store.load = this.original.load;
    store.save = this.original.save;
  },
};
