refactor: handle all admonitions via JSX component (#7152)

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
This commit is contained in:
Alexey Pyltsyn 2022-06-03 15:26:33 +03:00 committed by GitHub
parent 17fe43ecc8
commit 5746c58f41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 709 additions and 250 deletions

View file

@ -1,12 +1,32 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`validation schemas admonitionsSchema: for value=[] 1`] = `""value" must be of type object"`;
exports[`validation schemas admonitionsSchema: for value=[] 1`] = `""value" does not look like a valid admonitions config"`;
exports[`validation schemas admonitionsSchema: for value=3 1`] = `""value" must be of type object"`;
exports[`validation schemas admonitionsSchema: for value={"customTypes":{"myKeyword":{"keyword":"myKeyword","infima":true,"svg":"<svg width=\\"512px\\" height=\\"512px\\" viewBox=\\"0 0 512 512\\" xmlns=\\"http://www.w3.org/2000/svg\\"></svg>"}}} 1`] = `
"The Docusaurus admonitions system has changed, and the option "customTypes" does not exist anymore.
You now need to swizzle the admonitions component to provide UI customizations such as icons.
Please refer to https://github.com/facebook/docusaurus/pull/7152 for detailed upgrade instructions."
`;
exports[`validation schemas admonitionsSchema: for value=null 1`] = `""value" must be of type object"`;
exports[`validation schemas admonitionsSchema: for value={"icons":"emoji"} 1`] = `
"The Docusaurus admonitions system has changed, and the option "icons" does not exist anymore.
You now need to swizzle the admonitions component to provide UI customizations such as icons.
Please refer to https://github.com/facebook/docusaurus/pull/7152 for detailed upgrade instructions."
`;
exports[`validation schemas admonitionsSchema: for value=true 1`] = `""value" must be of type object"`;
exports[`validation schemas admonitionsSchema: for value={"infima":true} 1`] = `
"The Docusaurus admonitions system has changed, and the option "infima" does not exist anymore.
You now need to swizzle the admonitions component to provide UI customizations such as icons.
Please refer to https://github.com/facebook/docusaurus/pull/7152 for detailed upgrade instructions."
`;
exports[`validation schemas admonitionsSchema: for value={"keywords":[]} 1`] = `""keywords" does not contain 1 required value(s)"`;
exports[`validation schemas admonitionsSchema: for value={"tag":""} 1`] = `""tag" is not allowed to be empty"`;
exports[`validation schemas admonitionsSchema: for value={"unknownAttribute":"val"} 1`] = `""unknownAttribute" is not allowed"`;
exports[`validation schemas admonitionsSchema: for value=3 1`] = `""value" does not look like a valid admonitions config"`;
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."`;

View file

@ -87,17 +87,39 @@ describe('validation schemas', () => {
it('admonitionsSchema', () => {
const {testOK, testFail} = createTestHelpers({
schema: AdmonitionsSchema,
defaultValue: {},
defaultValue: true,
});
testOK(undefined);
testOK(true);
testOK(false);
testOK({});
testOK({attr: 'val'});
testOK({tag: '+++'});
testOK({keywords: ['info', 'tip']});
testOK({tag: '+++', keywords: ['info', 'tip']});
testFail(null);
testFail(3);
testFail(true);
testFail([]);
testFail({unknownAttribute: 'val'});
testFail({tag: ''});
testFail({keywords: []});
// Legacy types
testFail({
infima: true,
});
testFail({
icons: 'emoji',
});
testFail({
customTypes: {
myKeyword: {
keyword: `myKeyword`,
infima: true,
svg: '<svg width="512px" height="512px" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"></svg>',
},
},
});
});
it('remarkPluginsSchema', () => {