45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
|
|
import { describe, expect, it } from 'vitest';
|
||
|
|
|
||
|
|
import {
|
||
|
|
RESIDENCE_TYPES,
|
||
|
|
createResidentialInterestSchema,
|
||
|
|
updateResidentialInterestSchema,
|
||
|
|
} from '@/lib/validators/residential';
|
||
|
|
|
||
|
|
describe('residential interest residenceType', () => {
|
||
|
|
it('accepts a known residence type', () => {
|
||
|
|
const parsed = createResidentialInterestSchema.parse({
|
||
|
|
residentialClientId: 'rc_1',
|
||
|
|
residenceType: 'Two Bedroom Marina Villa',
|
||
|
|
});
|
||
|
|
expect(parsed.residenceType).toBe('Two Bedroom Marina Villa');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('coerces empty string to null (inline-select clear)', () => {
|
||
|
|
const parsed = updateResidentialInterestSchema.parse({ residenceType: '' });
|
||
|
|
expect(parsed.residenceType).toBeNull();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('accepts explicit null', () => {
|
||
|
|
const parsed = updateResidentialInterestSchema.parse({ residenceType: null });
|
||
|
|
expect(parsed.residenceType).toBeNull();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('rejects an unknown residence type', () => {
|
||
|
|
expect(() =>
|
||
|
|
createResidentialInterestSchema.parse({
|
||
|
|
residentialClientId: 'rc_1',
|
||
|
|
residenceType: 'Penthouse Suite',
|
||
|
|
}),
|
||
|
|
).toThrow();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('exposes the three offered unit types', () => {
|
||
|
|
expect(RESIDENCE_TYPES).toEqual([
|
||
|
|
'Two Bedroom Marina Villa',
|
||
|
|
'Four Bedroom Oceanfront Villa',
|
||
|
|
'Five Bedroom Oceanfront Villa',
|
||
|
|
]);
|
||
|
|
});
|
||
|
|
});
|