import { inflateDataOverlayState, inflateInitialDataOverlayState, inflateInitialMcadObjectState, inflateInitialScanState, inflateMcadObjectState, inflateScanState, } from '@/functions/modelHelper'; import { AnchorPoint, InteractionType, ScanView } from '@3cr/types-ts'; import { cSlider, getCurrentView, setInitialScanStateFromPayload, setScanState, setScanStateFromPayload, sSlider, thresholdSlider, tSlider, windowSlider, } from '@/models/scanState'; import { DataOverlayDataFaker } from '@test/fakers/data-overlay-data.faker'; import { McadObjectInteractionFaker } from '@test/fakers/mcad-object-interaction.faker'; import { useDataOverlayStore } from '@/stores/data-overlay.store'; import { useMcadStore } from '@/stores/mcad.store'; describe('scanState tests', () => { const dataOverlayStore = useDataOverlayStore(); const mcadStore = useMcadStore(); it('should getCurrentView Sagittal', () => { expect( getCurrentView({ Anchor: AnchorPoint.CENTER, ActiveView: true, AspectRatio: 1, MaxSize: { Version: '0.0.1', X: 1, Y: 1, }, DefaultView: ScanView.Coronal, Priority: 1, Version: '0.0.1', Offset: { Version: '0.0.1', X: 1, Y: 1, }, }), ).toBe(3); }); it('should getCurrentView Sagittal', () => { const initalState = inflateScanState(); initalState.Layout.PositionData = [ { Anchor: AnchorPoint.CENTER, ActiveView: true, AspectRatio: 1, MaxSize: { Version: '1.0.0', X: 1, Y: 1, }, DefaultView: ScanView.Coronal, Priority: 1, Offset: { Version: '1.0.0', X: 1, Y: 1, }, Version: '1.0.0', }, ]; setScanState(JSON.stringify(initalState)); expect( getCurrentView({ Anchor: AnchorPoint.CENTER, ActiveView: true, AspectRatio: 1, MaxSize: { Version: '0.0.1', X: 1, Y: 1, }, DefaultView: ScanView.Coronal, Priority: 1, Version: '0.0.1', Offset: { Version: '0.0.1', X: 1, Y: 1, }, }), ).toBe(0); }); it('should get/set sagittal slider', () => { sSlider.value = [0, 100]; expect(sSlider.value[0]).toBe(0); expect(sSlider.value[1]).toBe(100); }); it('should get/set coronal slider', () => { cSlider.value = [0, 100]; expect(cSlider.value[0]).toBe(0); expect(cSlider.value[1]).toBe(100); }); it('should get/set transverse slider', () => { tSlider.value = [0, 100]; expect(tSlider.value[0]).toBe(0); expect(tSlider.value[1]).toBe(100); }); it('should set window slider', () => { expect(windowSlider.value).toStrictEqual([0, 100]); }); it('should set threshold slider', () => { expect(thresholdSlider.value).toStrictEqual([0, 100]); }); describe('set states', () => { it('should set initial scan state', () => { const payload = JSON.stringify(inflateInitialScanState()); expect(() => setInitialScanStateFromPayload(payload)).not.toThrow(); }); it('should set current scan state', () => { const payload = JSON.stringify(inflateScanState()); expect(() => setScanStateFromPayload(payload)).not.toThrow(); }); it('should set initial data overlay state', () => { const payload = JSON.stringify(inflateInitialDataOverlayState()); expect(() => dataOverlayStore.setInitialDataOverlayState(payload), ).not.toThrow(); }); it('should set current data overlay state', () => { const payload = JSON.stringify(inflateDataOverlayState()); expect(() => dataOverlayStore.setDataOverlayState(payload)).not.toThrow(); }); it('should set data overlay event', () => { const payload = JSON.stringify( DataOverlayDataFaker.annotationEventRaw(InteractionType.HOVER_START), ); expect(() => dataOverlayStore.setDataOverlayEvent(payload)).not.toThrow(); }); it('should set initial mcad state', () => { const payload = JSON.stringify(inflateInitialMcadObjectState()); expect(() => mcadStore.setInitialMcadState(payload)).not.toThrow(); }); it('should set current data overlay state', () => { const payload = JSON.stringify(inflateMcadObjectState()); expect(() => mcadStore.setMcadState(payload)).not.toThrow(); }); it('should set data overlay event', () => { const payload = JSON.stringify( McadObjectInteractionFaker.randomRaw(InteractionType.HOVER_START), ); expect(() => mcadStore.setMcadEvent(payload)).not.toThrow(); }); }); });