Files
TREK/server/tests/unit/db/tour-paddle-columns.test.ts
Maurice c9e1e8ad86 test(tours): the reasons a region request waits for are pinned to the contract
knip found PaddleRegionRequestsReason exported and imported nowhere. Like the boat, water and lake style columns, the CHECK list of the column (044700) is now held against paddleRegionWaitReasonSchema, so a reason one side knows and the other refuses fails a test instead of an insert.
2026-10-18 21:35:02 +00:00

37 lines
1.6 KiB
TypeScript

import { PaddleRegionRequestsReason } from '../../../src/db/entities/PaddleRegionRequests.entity';
import { ToursBoatType, ToursPaddleLakeStyle, ToursWaterContext } from '../../../src/db/entities/Tours.entity';
import {
paddleBoatTypeSchema,
paddleLakeStyleSchema,
paddleRegionWaitReasonSchema,
paddleWaterContextSchema,
} from '@trek/shared';
import { describe, expect, it } from 'vitest';
/**
* The boat, water and lake style columns hold a CHECK list (migrations 043900
* and 044600) that the
* entity carries as its enum, and the contract holds its own list. A value
* one side knows and the other refuses would be a tour the planner can save
* and the database cannot store, or the other way round. A region request's
* reason (044700) is held the same way against the planner's answer.
*/
describe('paddle columns match the contract', () => {
it('knows the same boats as the paddle contract', () => {
expect(Object.values(ToursBoatType).sort()).toEqual([...paddleBoatTypeSchema.options].sort());
});
it('knows the same waters as the paddle contract', () => {
expect(Object.values(ToursWaterContext).sort()).toEqual([...paddleWaterContextSchema.options].sort());
});
it('knows the same lake styles as the paddle contract (PAD-11)', () => {
expect(Object.values(ToursPaddleLakeStyle).sort()).toEqual([...paddleLakeStyleSchema.options].sort());
});
it('knows the same reasons a region request waits for as the region contract (PAD-11C)', () => {
expect(Object.values(PaddleRegionRequestsReason).sort()).toEqual([...paddleRegionWaitReasonSchema.options].sort());
});
});