Add tests for route_config, but needs more assertions.
parent
ca5a0c6b82
commit
9e73fcecb8
|
@ -1,7 +1,16 @@
|
|||
import { topLevelRoutes } from "./route_config";
|
||||
jest.mock("fastclick", () => ({ attach: jest.fn() }));
|
||||
|
||||
import { topLevelRoutes } from "../route_config";
|
||||
|
||||
const cb = jest.fn(() => {
|
||||
console.log("TADA!");
|
||||
});
|
||||
|
||||
describe("route configs", () => {
|
||||
it("generates all of them", () => {
|
||||
topLevelRoutes
|
||||
it("generates all of them", async () => {
|
||||
const routes = topLevelRoutes.childRoutes;
|
||||
const results = await Promise.all(routes.map(route => route.getComponent(undefined, cb)));
|
||||
console.log("IMPROVE THESE TESTS THEY ARE NOT GOOD RIGHT NOW");
|
||||
expect(cb).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -15,9 +15,9 @@ function page(path: string, getter: () => Promise<React.ReactType>) {
|
|||
return {
|
||||
path,
|
||||
getComponent(_: void, cb: Function) {
|
||||
getter()
|
||||
.then(component => cb(undefined, component))
|
||||
.catch((e: object) => cb(undefined, crashPage(e)));
|
||||
const ok = (component: React.ReactType) => cb(undefined, component);
|
||||
const no = (e: object) => cb(undefined, crashPage(e));
|
||||
return getter().then(ok, no);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue