import { ScanView } from '@3cr/types-ts'; import { DOMWrapper, mount } from '@vue/test-utils'; import Rotate2dAction from '@/components/modal/actions/Rotate2dAction.vue'; import { useViewer3cr } from '@/composables/useViewer3cr'; import { VTextField } from 'vuetify/components'; describe('Rotate2dAction tests', () => { const viewer3cr = useViewer3cr(); it('should apply rotation', async () => { const props = { view: ScanView.Sagittal }; const spy = vi.spyOn(viewer3cr, 'rotateByDeg').mockResolvedValue(); const wrapper = mount(Rotate2dAction, { props }); const button = wrapper.findComponentByTestId('button'); await button.trigger('click'); const menu = new DOMWrapper(document.querySelector('[data-testid="menu"]')); const textField = menu.findComponentByTestId('rotate'); await textField.setValue(10); const rotate = menu.findComponentByTestId('rotate'); await rotate.trigger('click'); const text = menu.findComponent(VTextField); await text.setValue(123); expect(spy).toHaveBeenCalledWith({ message: { Version: '0.0.0', View: ScanView.Sagittal, Angle: 0 }, }); }); });