Files
ohif-viewer/extensions/cornerstone/src/utils/getCornerstoneOrientation.test.ts
T
Bill Wallace 760adc50d6 Reformat in HP MPR (#5717)
* Reformat in HP MPR

* fix: Orientation markers should work
2026-04-14 13:56:20 -04:00

79 lines
2.8 KiB
TypeScript

import { Enums } from '@cornerstonejs/core';
import getCornerstoneOrientation from './getCornerstoneOrientation';
jest.mock('@cornerstonejs/core', () => ({
Enums: {
OrientationAxis: {
AXIAL: 'axial',
SAGITTAL: 'sagittal',
CORONAL: 'coronal',
ACQUISITION: 'acquisition',
AXIAL_REFORMAT: 'axial_reformat',
SAGITTAL_REFORMAT: 'sagittal_reformat',
CORONAL_REFORMAT: 'coronal_reformat',
},
},
}));
describe('getCornerstoneOrientation', () => {
it('should return AXIAL when orientation is axial', () => {
const result = getCornerstoneOrientation('axial');
expect(result).toBe(Enums.OrientationAxis.AXIAL);
});
it('should return AXIAL when orientation is AXIAL (uppercase)', () => {
const result = getCornerstoneOrientation('AXIAL');
expect(result).toBe(Enums.OrientationAxis.AXIAL);
});
it('should return SAGITTAL when orientation is sagittal', () => {
const result = getCornerstoneOrientation('sagittal');
expect(result).toBe(Enums.OrientationAxis.SAGITTAL);
});
it('should return CORONAL when orientation is coronal', () => {
const result = getCornerstoneOrientation('coronal');
expect(result).toBe(Enums.OrientationAxis.CORONAL);
});
it('should return AXIAL_REFORMAT when orientation is axial_reformat', () => {
const result = getCornerstoneOrientation('axial_reformat');
expect(result).toBe(Enums.OrientationAxis.AXIAL_REFORMAT);
});
it('should return SAGITTAL_REFORMAT when orientation is sagittal_reformat', () => {
const result = getCornerstoneOrientation('sagittal_reformat');
expect(result).toBe(Enums.OrientationAxis.SAGITTAL_REFORMAT);
});
it('should return CORONAL_REFORMAT when orientation is coronal_reformat', () => {
const result = getCornerstoneOrientation('coronal_reformat');
expect(result).toBe(Enums.OrientationAxis.CORONAL_REFORMAT);
});
it('should return ACQUISITION for unknown orientation', () => {
const result = getCornerstoneOrientation('unknown');
expect(result).toBe(Enums.OrientationAxis.ACQUISITION);
});
it('should return ACQUISITION when orientation is null', () => {
const result = getCornerstoneOrientation(null);
expect(result).toBe(Enums.OrientationAxis.ACQUISITION);
});
it('should return ACQUISITION when orientation is undefined', () => {
const result = getCornerstoneOrientation(undefined);
expect(result).toBe(Enums.OrientationAxis.ACQUISITION);
});
it('should return ACQUISITION when orientation is empty string', () => {
const result = getCornerstoneOrientation('');
expect(result).toBe(Enums.OrientationAxis.ACQUISITION);
});
it('should handle mixed case orientation', () => {
const result = getCornerstoneOrientation('CoRoNaL');
expect(result).toBe(Enums.OrientationAxis.CORONAL);
});
});