-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apollo-client: Add tests for ApolloClient initialization
- Loading branch information
1 parent
c30a426
commit aea7959
Showing
2 changed files
with
105 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
definitions/npm/apollo-client_v2.x.x/test_apollo-client_v2.x.x.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// @flow | ||
|
||
import { ApolloClient, ApolloLink, ApolloCache } from "apollo-client"; | ||
import { describe, it } from "flow-typed-test"; | ||
|
||
const link = new ApolloLink(); | ||
const cache = new ApolloCache(); | ||
|
||
describe("apollo-client", () => { | ||
describe("ApolloClient initialization", () => { | ||
it("passes when passed correct configuration", () => { | ||
new ApolloClient({ | ||
link, | ||
cache | ||
}); | ||
}); | ||
|
||
it("passes when passed optional cnfig options", () => { | ||
new ApolloClient({ | ||
link, | ||
cache, | ||
ssrMode: true, | ||
ssrForceFetchDelay: 1000, | ||
connectToDevTools: true, | ||
queryDeduplication: true, | ||
defaultOptions: { | ||
query: { | ||
fetchPolicy: "cache-and-network" | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
it("raises error when missing link", () => { | ||
// $ExpectError - link required to initialize ApolloClient | ||
new ApolloClient({ | ||
cache | ||
}); | ||
}); | ||
|
||
it("raises error when missing cache", () => { | ||
// $ExpectError - cache required to initialize ApolloClient | ||
new ApolloClient({ | ||
link | ||
}); | ||
}); | ||
|
||
it("raises error when passing invalid connectToDevTools", () => { | ||
// $ExpectError - connectToDevTools must be boolean | ||
new ApolloClient({ | ||
link, | ||
cache, | ||
connectToDevTools: "true" | ||
}); | ||
}); | ||
|
||
it("raises error when passing invalid ssrMode", () => { | ||
// $ExpectError - ssrMode must be boolean | ||
new ApolloClient({ | ||
link, | ||
cache, | ||
ssrMode: "true" | ||
}); | ||
}); | ||
|
||
it("raises error when passing invalid ssrForceFetchDelay", () => { | ||
// $ExpectError - ssrForceFetchDelay must be number | ||
new ApolloClient({ | ||
link, | ||
cache, | ||
ssrForceFetchDelay: "true" | ||
}); | ||
}); | ||
|
||
it("raises error when passing invalid queryDeduplication", () => { | ||
// $ExpectError - queryDeduplication must be boolean | ||
new ApolloClient({ | ||
link, | ||
cache, | ||
queryDeduplication: "true" | ||
}); | ||
}); | ||
|
||
it("raises error when passing invalid defaultOptions", () => { | ||
// $ExpectError - defaultOptions fetchPolicy is invalid | ||
new ApolloClient({ | ||
link, | ||
cache, | ||
defaultOptions: { | ||
query: { | ||
fetchPolicy: "invalidFetchPolicy" | ||
} | ||
} | ||
}); | ||
}); | ||
}); | ||
}); |