mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-24 13:38:02 +02:00
test(utils, mdx-loader, core): improve coverage (#6303)
* test(utils, mdx-loader, core): improve coverage * windows... * fix
This commit is contained in:
parent
cf265c051e
commit
a79c23bc45
38 changed files with 841 additions and 219 deletions
|
@ -8,6 +8,10 @@ exports[`validation schemas AdmonitionsSchema: for value=null 1`] = `"\\"value\\
|
|||
|
||||
exports[`validation schemas AdmonitionsSchema: for value=true 1`] = `"\\"value\\" must be of type object"`;
|
||||
|
||||
exports[`validation schemas PathnameSchema: for value="foo" 1`] = `"\\"value\\" is not a valid pathname. Pathname should start with slash and not contain any domain or query string."`;
|
||||
|
||||
exports[`validation schemas PathnameSchema: for value="https://github.com/foo" 1`] = `"\\"value\\" is not a valid pathname. Pathname should start with slash and not contain any domain or query string."`;
|
||||
|
||||
exports[`validation schemas PluginIdSchema: for value="/docs" 1`] = `"\\"value\\" with value \\"/docs\\" fails to match the required pattern: /^[a-zA-Z_-]+$/"`;
|
||||
|
||||
exports[`validation schemas PluginIdSchema: for value="do cs" 1`] = `"\\"value\\" with value \\"do cs\\" fails to match the required pattern: /^[a-zA-Z_-]+$/"`;
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
RemarkPluginsSchema,
|
||||
PluginIdSchema,
|
||||
URISchema,
|
||||
PathnameSchema,
|
||||
} from '../validationSchemas';
|
||||
|
||||
function createTestHelpers({
|
||||
|
@ -128,4 +129,12 @@ describe('validation schemas', () => {
|
|||
testOK(protocolRelativeUrl1);
|
||||
testOK(protocolRelativeUrl2);
|
||||
});
|
||||
|
||||
test('PathnameSchema', () => {
|
||||
const {testFail, testOK} = createTestHelpers({schema: PathnameSchema});
|
||||
|
||||
testOK('/foo');
|
||||
testFail('foo');
|
||||
testFail('https://github.com/foo');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -36,6 +36,17 @@ describe('validateFrontMatter', () => {
|
|||
);
|
||||
});
|
||||
|
||||
test('should not convert simple values', () => {
|
||||
const schema = Joi.object({
|
||||
test: JoiFrontMatter.string(),
|
||||
});
|
||||
const frontMatter = {
|
||||
test: 'foo',
|
||||
tags: ['foo', 'bar'],
|
||||
};
|
||||
expect(validateFrontMatter(frontMatter, schema)).toEqual(frontMatter);
|
||||
});
|
||||
|
||||
// Fix Yaml trying to convert strings to numbers automatically
|
||||
// We only want to deal with a single type in the final frontmatter (not string | number)
|
||||
test('should convert number values to string when string schema', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue