import rewiremock from 'rewiremock'; import '../../../../mocks/electron'; import { expect } from 'chai'; import 'mocha'; import { load, save } from './store'; describe('Store Service', function () { this.timeout(10000); before(() => { rewiremock.enable(); }); after(() => { rewiremock.disable(); }); it('loads saved data', () => { const testData: any = { something: 'gaga', somethingElse: 0, deepObject: { somethingAsWell: true, somethingNotInJson: undefined, someArray: [ 'hui', { g: 'h', }, ], }, }; const expectedJson = JSON.stringify(testData); return save(StoreKey.COOKIES, testData) .then(() => load(StoreKey.COOKIES)) .then((data) => { expect(JSON.stringify(data)).to.equal(expectedJson, 'store does not save and load data correctly'); return load(StoreKey.COOKIES); }) .then((data) => { expect(JSON.stringify(data)).to.equal(expectedJson, 'store does not load data correctly when loaded twice'); }); }); });