Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(v2): fix async tests #2906

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions packages/docusaurus-1.x/lib/server/__tests__/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ describe('server utils', () => {
const css = await utils.minifyCss(testCss);
expect(css).toMatchSnapshot();

try {
await utils.minifyCss(notCss);
} catch (error) {
expect(error).toMatchSnapshot();
}
await expect(utils.minifyCss(notCss)).rejects.toMatchSnapshot();
});

test('autoprefix css', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ Array [
`;

exports[`site with wrong sidebar file 1`] = `
[Error: Bad sidebars file. The document id 'goku' was used in the sidebar, but no document with this id could be found.
"Bad sidebars file. The document id 'goku' was used in the sidebar, but no document with this id could be found.
Available document ids=
- foo/bar
- foo/baz
- hello
- ipsum
- lorem]
- lorem"
`;

exports[`versioned website content 1`] = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test('site with wrong sidebar file', async () => {
const plugin = pluginContentDocs(context, {
sidebarPath,
});
return plugin.loadContent().catch((e) => expect(e).toMatchSnapshot());
await expect(plugin.loadContent()).rejects.toThrowErrorMatchingSnapshot();
});

describe('empty/no docs website', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,16 @@ describe('simple site', () => {
routeBasePath,
};

return processMetadata({
source: 'invalid-id.md',
refDir: path.join(badSiteDir, 'docs'),
context,
options,
env,
}).catch((e) =>
expect(e).toMatchInlineSnapshot(
`[Error: Document id cannot include "/".]`,
),
await expect(
processMetadata({
source: 'invalid-id.md',
refDir: path.join(badSiteDir, 'docs'),
context,
options,
env,
}),
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Document id cannot include \\"/\\"."`,
);
});

Expand All @@ -196,16 +196,16 @@ describe('simple site', () => {
routeBasePath,
};

return processMetadata({
source: 'invalid-slug.md',
refDir: path.join(badSiteDir, 'docs'),
context,
options,
env,
}).catch((e) =>
expect(e).toMatchInlineSnapshot(
`[Error: Document slug cannot include "/".]`,
),
await expect(
processMetadata({
source: 'invalid-slug.md',
refDir: path.join(badSiteDir, 'docs'),
context,
options,
env,
}),
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Document slug cannot include \\"/\\"."`,
);
});
});
Expand Down