import { mount, VueWrapper } from '@vue/test-utils'; import AnnotationGeneratedSnackbar from '@/components/modal/snackbars/AnnotationGeneratedSnackbar.vue'; import { VSnackbar } from 'vuetify/components'; describe('AnnotationGeneratedSnackbar', () => { let wrapper: VueWrapper; beforeEach(() => { wrapper = mount(AnnotationGeneratedSnackbar, { props: { modelValue: false }, }); }); afterEach(() => { wrapper.unmount(); }); it('should render the snackbar correctly', async () => { const snack = wrapper.findComponent(VSnackbar); await snack.setValue(true); expect(snack.isVisible()).toBe(true); }); it('should close the snackbar when close icon is clicked', async () => { await wrapper.setProps({ modelValue: true }); const closeButton = wrapper.findComponent('[data-testid="closeBtn"]'); await closeButton.trigger('click'); expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([false]); }); it('should call undo function and close the snackbar', async () => { await wrapper.setProps({ modelValue: true }); const undoButton = wrapper.findComponent('[data-testid="undoBtn"]'); await undoButton.trigger('click'); expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([false]); }); it('should update modelValue and bind correctly via v-model', async () => { await wrapper.setProps({ modelValue: true }); const snackbar = wrapper.findComponent(VSnackbar); expect(snackbar.props('modelValue')).toBe(true); await wrapper.setProps({ modelValue: false }); expect(snackbar.props('modelValue')).toBe(false); }); });