A test file under packages/client now says which face it covers:
`*.client.spec.{ts,tsx}` and its `*.client.{ts,tsx}` helpers belong to the
Client aggregate, `*.host.spec.ts` to the host aggregate. The carrier's four
node-half specs take the Host suffix.
The two suffixes are mutually exclusive, so each aggregate excludes the
other's and both keep one broad test glob: `exclude` wins over `include`, and
`packages/client/**` no longer has to be excluded wholesale from the host
program with per-file `files` entries carved back out of it. A Host-face spec
that reaches only Host source therefore needs no cross-face project
reference, which the split-project rule rejects.
vitest still discovers every file through `**/*.spec.{ts,tsx}`.
39 lines
2.0 KiB
TypeScript
39 lines
2.0 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { describe, expect, it } from 'vitest'
|
|
import { Context } from '@deepseek-ai/cordis'
|
|
import { apply as nodeApply } from '@deepseek-ai/dsh-client-locale'
|
|
import { apply as clientApply, COMMON_NS, LocaleService, inject } from '@deepseek-ai/dsh-client-locale/client'
|
|
import * as LocaleInvariant from '@deepseek-ai/dsh-client-locale/invariant'
|
|
import { SlotsService } from '@deepseek-ai/dsh-client-runtime/client'
|
|
import InvariantService from '@deepseek-ai/dsh-invariants'
|
|
import { stubSettingsScope } from '@deepseek-ai/dsh-client-test-runtime'
|
|
|
|
describe('invariant companion', () => {
|
|
it('registers under the package name with an empty installer', async () => {
|
|
const ctx = new Context()
|
|
await ctx.plugin(InvariantService, { enabled: true })
|
|
await expect(ctx.plugin(LocaleInvariant).await()).resolves.toBeDefined()
|
|
})
|
|
|
|
it('node-half apply tolerates a Host without settings', () => {
|
|
nodeApply(new Context())
|
|
})
|
|
|
|
it('client apply provides ctx.locale seeded with the zh/en common namespace', async () => {
|
|
// The feature registers its own Language settings row, hence the slots edge.
|
|
expect(inject).toEqual(['slots', 'connection', 'remote', 'settingsScope'])
|
|
const ctx = new Context()
|
|
new SlotsService(ctx)
|
|
ctx.provide('connection', { api: { settings: {} }, isLoopback: false } as never)
|
|
// The settings row's transport and the forwarded-event port.
|
|
ctx.provide('remote', { $on: () => () => {} } as never)
|
|
ctx.provide('settingsScope', { bind: () => stubSettingsScope().scope } as never)
|
|
await ctx.plugin({ inject, apply: clientApply }).await()
|
|
const locale = ctx.get('locale')
|
|
expect(locale).toBeInstanceOf(LocaleService)
|
|
// Seeded dictionaries occupy the (ns, locale) seats even while empty.
|
|
expect(() => (locale as LocaleService).register(COMMON_NS, 'zh', {})).toThrow('already has locale')
|
|
expect(() => (locale as LocaleService).register(COMMON_NS, 'en', {})).toThrow('already has locale')
|
|
})
|
|
})
|