Add integration tests!

This commit is contained in:
Chi Vinh Le
2018-07-06 21:19:49 -03:00
parent d7acd23884
commit 84dd673c2e
25 changed files with 657 additions and 145 deletions
@@ -7,6 +7,7 @@ export { default as QueryRenderer } from "./QueryRenderer";
export * from "./QueryRenderer";
export { default as createMutationContainer } from "./createMutationContainer";
export { default as createAndRetain } from "./createAndRetain";
export { default as wrapFetchWithLogger } from "./wrapFetchWithLogger";
export {
commitMutationPromise,
commitMutationPromiseNormalized,
@@ -0,0 +1,25 @@
import { FetchFunction } from "relay-runtime";
/**
* Decorates the fetch function with error logging.
* Intended for testing purposes.
*/
export default function wrapFetchWithLogger(
fetch: FetchFunction,
logResult?: boolean
): FetchFunction {
return async (...args: any[]) => {
try {
const result = await (fetch as any)(...args);
if (logResult) {
// tslint:disable-next-line:no-console
console.log(JSON.stringify(result));
}
return result;
} catch (err) {
// tslint:disable-next-line:no-console
console.error(err);
throw err;
}
};
}