feat: config tests

This commit is contained in:
Florian Lefebvre 2025-01-20 15:39:20 +01:00
parent d372335b99
commit 1dfdbdebde

View file

@ -370,7 +370,7 @@ describe('Config Validation', () => {
},
},
process.cwd(),
).catch((err) => err),
),
);
});
@ -385,7 +385,7 @@ describe('Config Validation', () => {
},
},
process.cwd(),
).catch((err) => err),
),
);
});
@ -427,4 +427,58 @@ describe('Config Validation', () => {
);
});
});
describe('fonts', () => {
it('Should allow empty providers and families', () => {
assert.doesNotThrow(() =>
validateConfig(
{
experimental: {
fonts: {
providers: [],
families: [],
},
},
},
process.cwd(),
),
);
});
it('Should not allow providers with reserved names', async () => {
let configError = await validateConfig(
{
experimental: {
fonts: {
providers: [{ name: 'google', entrypoint: '' }],
families: [],
},
},
},
process.cwd(),
).catch((err) => err);
assert.equal(configError instanceof z.ZodError, true);
assert.equal(
configError.errors[0].message.includes('"google" is a reserved provider name'),
true,
);
configError = await validateConfig(
{
experimental: {
fonts: {
providers: [{ name: 'local', entrypoint: '' }],
families: [],
},
},
},
process.cwd(),
).catch((err) => err);
assert.equal(configError instanceof z.ZodError, true);
assert.equal(
configError.errors[0].message.includes('"local" is a reserved provider name'),
true,
);
});
});
});