mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-13 08:12:48 +02:00
polish(v2): url-subpath config validation warning (#4977)
This commit is contained in:
parent
dfe32dac9e
commit
9fe79caadc
3 changed files with 51 additions and 5 deletions
|
@ -5,7 +5,11 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {DEFAULT_CONFIG, validateConfig} from '../configValidation';
|
||||
import {
|
||||
ConfigSchema,
|
||||
DEFAULT_CONFIG,
|
||||
validateConfig,
|
||||
} from '../configValidation';
|
||||
import {DocusaurusConfig} from '@docusaurus/types';
|
||||
|
||||
const baseConfig = {
|
||||
|
@ -197,3 +201,26 @@ describe('normalizeConfig', () => {
|
|||
).toThrowErrorMatchingSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('config warnings', () => {
|
||||
function getWarning(config: unknown) {
|
||||
return ConfigSchema.validate(config).warning;
|
||||
}
|
||||
|
||||
test('baseConfig has no warning', () => {
|
||||
const warning = getWarning(baseConfig);
|
||||
expect(warning).toBeUndefined();
|
||||
});
|
||||
|
||||
test('site url has warning when using subpath', () => {
|
||||
const warning = getWarning({
|
||||
...baseConfig,
|
||||
url: 'https://mysite.com/someSubpath',
|
||||
});
|
||||
expect(warning).toBeDefined();
|
||||
expect(warning?.details.length).toEqual(1);
|
||||
expect(warning?.details[0].message).toMatchInlineSnapshot(
|
||||
`"Docusaurus config validation warning. Field \\"url\\": the url is not supposed to contain a sub-path like '/someSubpath', please use the baseUrl field for sub-paths"`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue