Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
fix: Integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wtrocki committed May 13, 2019
1 parent 11309d8 commit 0270d68
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions packages/sync/integration_test/test/offline.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('Offline mutations', function () {
} catch (ignore) { }


const offlineKeys = await JSON.parse(store.getItem(offlineMetaKey));
const offlineKeys = await store.getItem(offlineMetaKey);
const offlineMutation = await store.getItem("offline:" + offlineKeys[0]);

expect(offlineMutation).to.exist;
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('Offline mutations', function () {
});
} catch (ignore) { }

const offlineKeys = await JSON.parse(store.getItem(offlineMetaKey));
const offlineKeys = await store.getItem(offlineMetaKey);
const offlineMutation1 = await store.getItem("offline:" + offlineKeys[0]);
const offlineMutation2 = await store.getItem("offline:" + offlineKeys[1]);

Expand Down Expand Up @@ -349,7 +349,7 @@ describe('Offline mutations', function () {
});
} catch (ignore) { }

const offlineKeys = await JSON.parse(store.getItem(offlineMetaKey));
const offlineKeys = await store.getItem(offlineMetaKey);
const offlineMutation1 = await store.getItem("offline:" + offlineKeys[0]);
const offlineMutation2 = await store.getItem("offline:" + offlineKeys[1]);

Expand Down Expand Up @@ -409,7 +409,7 @@ describe('Offline mutations', function () {
});
} catch (ignore) { }

const offlineKeys = await JSON.parse(store.getItem(offlineMetaKey));
const offlineKeys = await store.getItem(offlineMetaKey);
const offlineMutation1 = await store.getItem("offline:" + offlineKeys[0]);
const offlineMutation2 = await store.getItem("offline:" + offlineKeys[1]);

Expand Down Expand Up @@ -479,7 +479,7 @@ describe('Offline mutations', function () {
});
} catch (ignore) { }

const offlineKeys = await JSON.parse(store.getItem(offlineMetaKey));
const offlineKeys = await store.getItem(offlineMetaKey);
const offlineMutation = await store.getItem("offline:" + offlineKeys[0]);
expect(offlineMutation).to.exist;
networkStatus.setOnline(true);
Expand Down
4 changes: 3 additions & 1 deletion packages/sync/integration_test/utils/testStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ export class TestStore {
}

getItem(key) {
return this.data[key];
return Promise.resolve(this.data[key]);
}

setItem(key, data) {
this.data[key] = data;
return Promise.resolve();
}

removeItem(key) {
delete this.data[key];
return Promise.resolve();
}
}
2 changes: 1 addition & 1 deletion packages/sync/src/offline/OfflineMutationsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class OfflineMutationsHandler {
public replayOfflineMutations = async () => {
const offlineData = await this.store.getOfflineData();
// if there is no offline data then just exit
if (offlineData.length === 0) { return; }
if (offlineData && offlineData.length === 0) { return; }

logger("Replying offline mutations after application restart");
for (const item of offlineData) {
Expand Down

0 comments on commit 0270d68

Please sign in to comment.