RenaiApp/tests/main/services/store.mock.ts

34 lines
655 B
TypeScript
Raw Normal View History

const store = require('../../../src/main/services/store');
import { load, save } from '../../../src/main/services/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;
},
};