[ci] yarn format
This commit is contained in:
parent
3b4bbdc98d
commit
231020368e
1 changed files with 15 additions and 9 deletions
|
@ -7,36 +7,42 @@ import { formatConfigError, validateConfig } from '#astro/config';
|
||||||
const ConfigValidate = suite('Config Validation');
|
const ConfigValidate = suite('Config Validation');
|
||||||
|
|
||||||
ConfigValidate('empty user config is valid', async (context) => {
|
ConfigValidate('empty user config is valid', async (context) => {
|
||||||
const configError = await validateConfig({}, process.cwd()).catch(err => err);
|
const configError = await validateConfig({}, process.cwd()).catch((err) => err);
|
||||||
assert.ok(!(configError instanceof Error));
|
assert.ok(!(configError instanceof Error));
|
||||||
});
|
});
|
||||||
|
|
||||||
ConfigValidate('Zod errors are returned when invalid config is used', async (context) => {
|
ConfigValidate('Zod errors are returned when invalid config is used', async (context) => {
|
||||||
const configError = await validateConfig({buildOptions: {sitemap: 42}}, process.cwd()).catch(err => err);
|
const configError = await validateConfig({ buildOptions: { sitemap: 42 } }, process.cwd()).catch((err) => err);
|
||||||
assert.ok(configError instanceof z.ZodError);
|
assert.ok(configError instanceof z.ZodError);
|
||||||
});
|
});
|
||||||
|
|
||||||
ConfigValidate('A validation error can be formatted correctly', async (context) => {
|
ConfigValidate('A validation error can be formatted correctly', async (context) => {
|
||||||
const configError = await validateConfig({buildOptions: {sitemap: 42}}, process.cwd()).catch(err => err);
|
const configError = await validateConfig({ buildOptions: { sitemap: 42 } }, process.cwd()).catch((err) => err);
|
||||||
assert.ok(configError instanceof z.ZodError);
|
assert.ok(configError instanceof z.ZodError);
|
||||||
const formattedError = stripAnsi(formatConfigError(configError));
|
const formattedError = stripAnsi(formatConfigError(configError));
|
||||||
assert.equal(formattedError, `[config] Astro found issue(s) with your configuration:
|
assert.equal(
|
||||||
! buildOptions.sitemap Expected boolean, received number.`);
|
formattedError,
|
||||||
|
`[config] Astro found issue(s) with your configuration:
|
||||||
|
! buildOptions.sitemap Expected boolean, received number.`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
ConfigValidate('Multiple validation errors can be formatted correctly', async (context) => {
|
ConfigValidate('Multiple validation errors can be formatted correctly', async (context) => {
|
||||||
const veryBadConfig = {
|
const veryBadConfig = {
|
||||||
renderers: [42],
|
renderers: [42],
|
||||||
buildOptions: {pageUrlFormat: 'invalid'},
|
buildOptions: { pageUrlFormat: 'invalid' },
|
||||||
pages: {},
|
pages: {},
|
||||||
};
|
};
|
||||||
const configError = await validateConfig(veryBadConfig, process.cwd()).catch(err => err);
|
const configError = await validateConfig(veryBadConfig, process.cwd()).catch((err) => err);
|
||||||
assert.ok(configError instanceof z.ZodError);
|
assert.ok(configError instanceof z.ZodError);
|
||||||
const formattedError = stripAnsi(formatConfigError(configError));
|
const formattedError = stripAnsi(formatConfigError(configError));
|
||||||
assert.equal(formattedError, `[config] Astro found issue(s) with your configuration:
|
assert.equal(
|
||||||
|
formattedError,
|
||||||
|
`[config] Astro found issue(s) with your configuration:
|
||||||
! pages Expected string, received object.
|
! pages Expected string, received object.
|
||||||
! renderers.0 Expected string, received number.
|
! renderers.0 Expected string, received number.
|
||||||
! buildOptions.pageUrlFormat Invalid input.`);
|
! buildOptions.pageUrlFormat Invalid input.`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
ConfigValidate.run();
|
ConfigValidate.run();
|
||||||
|
|
Loading…
Reference in a new issue