mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-10 06:42:31 +02:00
fix(core): configValidation should allow inline theme functions (#6496)
This commit is contained in:
parent
c99026c524
commit
f5f598a921
3 changed files with 175 additions and 24 deletions
|
@ -117,6 +117,32 @@ describe('normalizeConfig', () => {
|
|||
}).toThrowErrorMatchingSnapshot();
|
||||
});
|
||||
|
||||
test.each([
|
||||
['should throw error if themes is not array', {}],
|
||||
[
|
||||
"should throw error if themes is not a string and it's not an array #1",
|
||||
[123],
|
||||
],
|
||||
[
|
||||
'should throw error if themes is not an array of [string, object][] #1',
|
||||
[['example/path', 'wrong parameter here']],
|
||||
],
|
||||
[
|
||||
'should throw error if themes is not an array of [string, object][] #2',
|
||||
[[{}, 'example/path']],
|
||||
],
|
||||
[
|
||||
'should throw error if themes is not an array of [string, object][] #3',
|
||||
[[{}, {}]],
|
||||
],
|
||||
])(`%s for the input of: %p`, (_message, themes) => {
|
||||
expect(() => {
|
||||
normalizeConfig({
|
||||
themes,
|
||||
});
|
||||
}).toThrowErrorMatchingSnapshot();
|
||||
});
|
||||
|
||||
test.each([
|
||||
['should accept [string] for plugins', ['plain/string']],
|
||||
[
|
||||
|
@ -155,6 +181,44 @@ describe('normalizeConfig', () => {
|
|||
}).not.toThrowError();
|
||||
});
|
||||
|
||||
test.each([
|
||||
['should accept [string] for themes', ['plain/string']],
|
||||
[
|
||||
'should accept string[] for themes',
|
||||
['plain/string', 'another/plain/string/path'],
|
||||
],
|
||||
[
|
||||
'should accept [string, object] for themes',
|
||||
[['plain/string', {it: 'should work'}]],
|
||||
],
|
||||
[
|
||||
'should accept [string, object][] for themes',
|
||||
[
|
||||
['plain/string', {it: 'should work'}],
|
||||
['this/should/work', {too: 'yes'}],
|
||||
],
|
||||
],
|
||||
[
|
||||
'should accept ([string, object]|string)[] for themes',
|
||||
[
|
||||
'plain/string',
|
||||
['plain', {it: 'should work'}],
|
||||
['this/should/work', {too: 'yes'}],
|
||||
],
|
||||
],
|
||||
['should accept function for theme', [function (_context, _options) {}]],
|
||||
[
|
||||
'should accept [function, object] for theme',
|
||||
[[function (_context, _options) {}, {it: 'should work'}]],
|
||||
],
|
||||
])(`%s for the input of: %p`, (_message, themes) => {
|
||||
expect(() => {
|
||||
normalizeConfig({
|
||||
themes,
|
||||
});
|
||||
}).not.toThrowError();
|
||||
});
|
||||
|
||||
test('should throw error if themes is not array', () => {
|
||||
expect(() => {
|
||||
normalizeConfig({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue