mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-03-22 20:43:10 -04:00
chore(frontend): harden settings parsing and update store imports
This commit is contained in:
@@ -44,6 +44,18 @@ describe('utils/settings', () => {
|
||||
expect(cfg.recommended.title).toBe('Recommended');
|
||||
});
|
||||
|
||||
test('Ignores non-string titles and keeps defaults', () => {
|
||||
const cfg = pagesConfig({
|
||||
latest: { title: null as any },
|
||||
featured: { title: 123 as any },
|
||||
recommended: { title: true as any },
|
||||
});
|
||||
|
||||
expect(cfg.latest.title).toBe('Recent uploads');
|
||||
expect(cfg.featured.title).toBe('Featured');
|
||||
expect(cfg.recommended.title).toBe('Recommended');
|
||||
});
|
||||
|
||||
test('Ignores unknown keys in settings', () => {
|
||||
const cfg = pagesConfig({
|
||||
// @ts-ignore
|
||||
|
||||
@@ -30,6 +30,16 @@ describe('utils/settings', () => {
|
||||
expect(res.tags).toStrictEqual({ enabled: true, title: 'My Tags' });
|
||||
});
|
||||
|
||||
test('Should ignore non-string title values and keep defaults', () => {
|
||||
const res = taxonomiesConfig({
|
||||
tags: { title: null as any },
|
||||
categories: { title: 123 as any },
|
||||
});
|
||||
|
||||
expect(res.tags).toStrictEqual({ enabled: true, title: 'Tags' });
|
||||
expect(res.categories).toStrictEqual({ enabled: true, title: 'Categories' });
|
||||
});
|
||||
|
||||
test('Should ignore unknown taxonomy keys', () => {
|
||||
const input = {
|
||||
unknownKey: { enabled: true, title: 'X' },
|
||||
|
||||
Reference in New Issue
Block a user