Files
dyolink/backend/src/modules/treatments/lab-case-send.validation.spec.ts

54 lines
1.7 KiB
TypeScript
Raw Normal View History

import { AppException } from '../../common/errors';
import { assertCompleteToothProsthesisMap } from './lab-case-send.validation';
describe('assertCompleteToothProsthesisMap', () => {
const prosthesisDetailId = 'detail-1';
it('passes when every prosthesis tooth has a mapping', () => {
expect(() =>
assertCompleteToothProsthesisMap({
details: [
{
treatmentDetailId: prosthesisDetailId,
detail: { id: prosthesisDetailId, treatmentType: 'prosthesis', teeth: ['14', '15'] },
},
],
toothProsthesis: [
{ treatmentDetailId: prosthesisDetailId, tooth: '14', prosthesisTypeCode: 'pfm_crown' },
{ treatmentDetailId: prosthesisDetailId, tooth: '15', prosthesisTypeCode: 'pfm_crown' },
],
}),
).not.toThrow();
});
it('ignores non-prosthesis details', () => {
expect(() =>
assertCompleteToothProsthesisMap({
details: [
{
treatmentDetailId: 'endo-1',
detail: { id: 'endo-1', treatmentType: 'endo', teeth: ['36'] },
},
],
toothProsthesis: [],
}),
).not.toThrow();
});
it('throws when a prosthesis tooth is missing from the map', () => {
expect(() =>
assertCompleteToothProsthesisMap({
details: [
{
treatmentDetailId: prosthesisDetailId,
detail: { id: prosthesisDetailId, treatmentType: 'prosthesis', teeth: ['14', '15'] },
},
],
toothProsthesis: [
{ treatmentDetailId: prosthesisDetailId, tooth: '14', prosthesisTypeCode: 'pfm_crown' },
],
}),
).toThrow(AppException);
});
});