mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-26 01:33:02 +00:00
VCS initialize could allow 0 arity functions
This commit is contained in:
parent
bc9e135ab5
commit
acfb1733de
|
|
@ -1495,6 +1495,24 @@ describe('future', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('accepts fn()', () => {
|
||||
const vcs: Partial<VcsConfig> = {
|
||||
initialize: () => null,
|
||||
};
|
||||
expect(
|
||||
normalizeConfig({
|
||||
future: {
|
||||
experimental_vcs: vcs,
|
||||
},
|
||||
}),
|
||||
).toEqual(
|
||||
vcsContaining({
|
||||
...DEFAULT_VCS_CONFIG,
|
||||
...vcs,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('accepts undefined', () => {
|
||||
const vcs: Partial<VcsConfig> = {
|
||||
initialize: undefined,
|
||||
|
|
@ -1546,23 +1564,7 @@ describe('future', () => {
|
|||
`);
|
||||
});
|
||||
|
||||
it('rejects fn()', () => {
|
||||
const vcs: Partial<VcsConfig> = {
|
||||
initialize: () => null,
|
||||
};
|
||||
expect(() =>
|
||||
normalizeConfig({
|
||||
future: {
|
||||
experimental_vcs: vcs,
|
||||
},
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`
|
||||
""future.experimental_vcs.initialize" must have an arity of 1
|
||||
"
|
||||
`);
|
||||
});
|
||||
|
||||
it('rejects fn(filePath, anotherArg)', () => {
|
||||
it('rejects fn(params, anotherArg)', () => {
|
||||
const vcs: Partial<VcsConfig> = {
|
||||
// @ts-expect-error: invalid
|
||||
initialize: (_params, _anotherArg) => null,
|
||||
|
|
@ -1574,7 +1576,7 @@ describe('future', () => {
|
|||
},
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`
|
||||
""future.experimental_vcs.initialize" must have an arity of 1
|
||||
""future.experimental_vcs.initialize" must have an arity lesser or equal to 1
|
||||
"
|
||||
`);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ const STORAGE_CONFIG_SCHEMA = Joi.object({
|
|||
|
||||
const VCS_CONFIG_SCHEMA = Joi.object<VcsConfig>({
|
||||
initialize: Joi.function()
|
||||
.arity(1)
|
||||
.maxArity(1)
|
||||
.optional()
|
||||
.default(() => DEFAULT_VCS_CONFIG.initialize),
|
||||
getFileCreationInfo: Joi.function()
|
||||
|
|
|
|||
Loading…
Reference in New Issue