test(settings): make third-review specs conform to strict optional and misused-promise contracts

Drop the explicit-undefined base fixture exactOptionalPropertyTypes
forbids (the repository trusts TypeScript at typed same-process seams —
no test for an input the static interface excludes; coverage holds), and
reshape the async-listener containment fixture as an unknown-returning
function: the earlier inline cast was silently stripped by the staged
oxlint fixer, leaving a shape the next lint pass rejects.
This commit is contained in:
Yichen Jiang
2026-07-30 14:13:15 +08:00
parent 3b1b912518
commit 2b379799ba

View File

@@ -228,14 +228,6 @@ describe('update', () => {
expect(scope.get()).toEqual({ theme: 'light', fontSize: 18 })
})
it('ignores an explicit undefined entry in the composition base layer', async () => {
const { ctx } = await boot({ doc: { 'ui-theme': { theme: 'light' } } })
const scope = ctx.settings.register(settingsNamespace('ui-theme'), ThemeSchema, {
base: { theme: undefined, fontSize: 16 },
})
expect(scope.get()).toEqual({ theme: 'light', fontSize: 16 })
})
it('rejects a non-object patch', async () => {
const { ctx } = await boot()
const scope = ctx.settings.register(settingsNamespace('ui-theme'), ThemeSchema)
@@ -616,12 +608,13 @@ describe('third review regressions', () => {
it('contains an async settings/updated listener rejection and keeps other listeners running', async () => {
const { ctx, provider } = await boot()
// An async listener violates the event's synchronous signature (typed
// consumers get a lint error for it), but an unlinted JS plugin can still
// register one; the cast simulates exactly that caller.
ctx.on('settings/updated', async () => {
throw new Error('async listener boom')
})
// An async listener violates the event's synchronous signature, but an
// unlinted JS plugin can still register one. Declaring the return as
// unknown keeps this file's typed surface legal (unknown-returning
// functions are assignable to void positions) while the runtime value is
// still the rejected promise the containment guard must handle.
const boom = (): unknown => Promise.reject(new Error('async listener boom'))
ctx.on('settings/updated', boom)
const second = vi.fn()
ctx.on('settings/updated', second)
ctx.settings.register(settingsNamespace('ui-theme'), ThemeSchema)