chore(v2): fix async tests (#2906)

This commit is contained in:
Sébastien Lorber 2020-06-08 19:10:13 +02:00 committed by GitHub
parent 66716d1619
commit 08359dd3ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 28 deletions

View file

@ -39,11 +39,7 @@ describe('server utils', () => {
const css = await utils.minifyCss(testCss); const css = await utils.minifyCss(testCss);
expect(css).toMatchSnapshot(); expect(css).toMatchSnapshot();
try { await expect(utils.minifyCss(notCss)).rejects.toMatchSnapshot();
await utils.minifyCss(notCss);
} catch (error) {
expect(error).toMatchSnapshot();
}
}); });
test('autoprefix css', async () => { test('autoprefix css', async () => {

View file

@ -110,13 +110,13 @@ Array [
`; `;
exports[`site with wrong sidebar file 1`] = ` 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= Available document ids=
- foo/bar - foo/bar
- foo/baz - foo/baz
- hello - hello
- ipsum - ipsum
- lorem] - lorem"
`; `;
exports[`versioned website content 1`] = ` exports[`versioned website content 1`] = `

View file

@ -45,7 +45,7 @@ test('site with wrong sidebar file', async () => {
const plugin = pluginContentDocs(context, { const plugin = pluginContentDocs(context, {
sidebarPath, sidebarPath,
}); });
return plugin.loadContent().catch((e) => expect(e).toMatchSnapshot()); await expect(plugin.loadContent()).rejects.toThrowErrorMatchingSnapshot();
}); });
describe('empty/no docs website', () => { describe('empty/no docs website', () => {

View file

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