Files
homaroma/packages/types/footer-layout.test.ts
T
2026-10-01 17:26:18 +07:00

47 lines
1.4 KiB
TypeScript

import { describe, expect, test } from 'bun:test'
import {
DEFAULT_FOOTER_LAYOUT_SETTINGS,
FooterLayoutSettingsPatchSchema,
FooterLayoutSettingsSchema,
} from './index'
describe('footer layout settings contract', () => {
test('keeps the legacy storefront presentation as the default', () => {
expect(FooterLayoutSettingsSchema.parse(DEFAULT_FOOTER_LAYOUT_SETTINGS)).toEqual(
DEFAULT_FOOTER_LAYOUT_SETTINGS,
)
})
test('rejects duplicate and unknown footer columns', () => {
const duplicate = FooterLayoutSettingsSchema.safeParse({
...DEFAULT_FOOTER_LAYOUT_SETTINGS,
columns: ['brand', 'brand'],
})
const unknown = FooterLayoutSettingsSchema.safeParse({
...DEFAULT_FOOTER_LAYOUT_SETTINGS,
columns: ['brand', 'legal'],
})
expect(duplicate.success).toBe(false)
expect(unknown.success).toBe(false)
})
test('rejects unknown presentation fields', () => {
expect(FooterLayoutSettingsSchema.safeParse({
...DEFAULT_FOOTER_LAYOUT_SETTINGS,
customCss: 'display: none',
}).success).toBe(false)
})
test('allows a partial nested finale patch but remains strict', () => {
expect(FooterLayoutSettingsPatchSchema.parse({
desktopColumns: 3,
finale: { enabled: false },
})).toEqual({ desktopColumns: 3, finale: { enabled: false } })
expect(FooterLayoutSettingsPatchSchema.safeParse({
finale: { height: '1000vh' },
}).success).toBe(false)
})
})