import { describe, expect, it } from 'vitest' import * as z from 'zod' import { baseConnectionShape, sshConfigSchema } from '../../../src/config/baseSchema.js' // A minimal concrete schema built from the shared base, the way a leaf package // would compose it. const testSchema = z.object({ ...baseConnectionShape, type: z.literal('test') }).strict() describe('sshConfigSchema', () => { it('defaults port to 22', () => { expect(sshConfigSchema.parse({ host: 'h', user: 'u' }).port).toBe(22) }) it('rejects unknown keys (strict)', () => { expect(() => sshConfigSchema.parse({ host: 'h', user: 'u', bogus: 1 })).toThrow() }) }) describe('baseConnectionShape', () => { it('accepts a valid connection and defaults readonly to false', () => { const c = testSchema.parse({ name: 'c1', host: 'h', user: 'u', type: 'test' }) expect(c.readonly).toBe(false) expect(c.port).toBeUndefined() }) it('requires user', () => { expect(() => testSchema.parse({ name: 'c1', host: 'h', type: 'test' })).toThrow() }) it('rejects an invalid name', () => { expect(() => testSchema.parse({ name: 'bad name!', host: 'h', user: 'u', type: 'test' }) ).toThrow() }) })