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

Commit

Permalink
fix: top level api unit tests
Browse files Browse the repository at this point in the history
Kinda raising this coverage thing that people get focused on
  • Loading branch information
wtrocki committed Apr 29, 2019
1 parent 38c6c40 commit a09d9f4
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/sync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
"@types/graphql": "14.2.0",
"@types/mocha": "5.2.6",
"@types/ws": "6.0.1",
"@types/fetch-mock": "^7.2.3",
"chai": "4.2.0",
"del": "4.1.1",
"fetch-mock": "^7.3.3",
"mocha": "6.1.4",
"ts-node": "8.1.0",
"typescript": "3.4.5"
Expand Down
4 changes: 2 additions & 2 deletions packages/sync/test/LocalDirectiveFilterLink.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from "chai";
import { requestWithMultipleDirectives, requestWithOnlineDirective } from "./operations";
import { TestLink } from "./TestUtils";
import { requestWithMultipleDirectives, requestWithOnlineDirective } from "./mock/operations";
import { TestLink } from "./mock/TestUtils";
import { ApolloLink, execute } from "apollo-link";
import { LocalDirectiveFilterLink } from "../src/links/LocalDirectiveFilterLink";
import { hasDirectives } from "apollo-utilities";
Expand Down
24 changes: 24 additions & 0 deletions packages/sync/test/OfflineClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { createClient, OfflineClient } from "../src";
import { expect, should } from "chai";
import { mock } from "fetch-mock";
import { storage } from "./mock/Storage";
import { networkStatus } from "./mock/NetworkState";

const url = "http://test";

describe("Top level api tests", () => {
before(() => {
mock(url, 200);
});
it("check old api", async () => {
const client = await createClient({
httpUrl: url, storage, networkStatus});
should().exist(client.offlineStore);
});

it("check new api", async () => {
const client = new OfflineClient({ httpUrl: url, storage, networkStatus });
const initClient = await client.init();
should().exist(initClient.offlineStore);
});
});
8 changes: 8 additions & 0 deletions packages/sync/test/mock/NetworkState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const networkStatus = {
isOffline() {
return Promise.resolve(false);
},
onStatusChangeListener() {
return;
}
};
12 changes: 12 additions & 0 deletions packages/sync/test/mock/Storage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const storage = {
getItem: () => {
console.info("Called");
return "{}";
},
setItem: () => {
console.info("Called");
},
removeItem: () => {
console.info("Called");
}
};
File renamed without changes.
File renamed without changes.

0 comments on commit a09d9f4

Please sign in to comment.