Logical API errors throw stable codes so users see translated messages instead of a generic bad request. Co-authored-by: Cursor <cursoragent@cursor.com>
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
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);
|
|
});
|
|
});
|