Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 committed Jan 22, 2020
1 parent 613b543 commit 64c8329
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default [
];
",
"routesPaths": Array [
"404.html",
"/404.html",
"/blog",
],
}
Expand Down Expand Up @@ -141,7 +141,7 @@ export default [
];
",
"routesPaths": Array [
"404.html",
"/404.html",
"/docs/hello",
"docs/foo/baz",
],
Expand Down Expand Up @@ -181,7 +181,7 @@ export default [
];
",
"routesPaths": Array [
"404.html",
"/404.html",
"",
],
}
Expand Down
23 changes: 12 additions & 11 deletions packages/docusaurus/src/server/__tests__/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('loadRoutes', () => {
},
],
};
const result = await loadRoutes([nestedRouteConfig]);
const result = await loadRoutes([nestedRouteConfig], '/');
expect(result).toMatchSnapshot();
});

Expand Down Expand Up @@ -64,7 +64,7 @@ describe('loadRoutes', () => {
],
},
};
const result = await loadRoutes([flatRouteConfig]);
const result = await loadRoutes([flatRouteConfig], '/');
expect(result).toMatchSnapshot();
});

Expand All @@ -73,20 +73,21 @@ describe('loadRoutes', () => {
component: 'hello/world.js',
} as RouteConfig;

expect(loadRoutes([routeConfigWithoutPath])).rejects.toMatchInlineSnapshot(`
[Error: Invalid routeConfig (Path must be a string and component is required)
{"component":"hello/world.js"}]
`);
expect(loadRoutes([routeConfigWithoutPath], '/')).rejects
.toMatchInlineSnapshot(`
[Error: Invalid routeConfig (Path must be a string and component is required)
{"component":"hello/world.js"}]
`);

const routeConfigWithoutComponent = {
path: '/hello/world',
} as RouteConfig;

expect(loadRoutes([routeConfigWithoutComponent])).rejects
expect(loadRoutes([routeConfigWithoutComponent], '/')).rejects
.toMatchInlineSnapshot(`
[Error: Invalid routeConfig (Path must be a string and component is required)
{"path":"/hello/world"}]
`);
[Error: Invalid routeConfig (Path must be a string and component is required)
{"path":"/hello/world"}]
`);
});

test('route config with empty (but valid) path string', async () => {
Expand All @@ -95,7 +96,7 @@ describe('loadRoutes', () => {
component: 'hello/world.js',
} as RouteConfig;

const result = await loadRoutes([routeConfig]);
const result = await loadRoutes([routeConfig], '/');
expect(result).toMatchSnapshot();
});
});

0 comments on commit 64c8329

Please sign in to comment.