import { flushPromises, mount } from '@vue/test-utils'; import AnnotationCreateSnackbar from '@/components/navigation/annotation/AnnotationCreateSnackbar.vue'; import { VSnackbar } from 'vuetify/components'; describe('Snackbar Component', () => { it('should mount', async () => { const wrapper = mount(AnnotationCreateSnackbar); await flushPromises(); expect(wrapper).toBeTruthy(); }); it('renders the snackbar with the correct text and icon', async () => { const wrapper = mount(AnnotationCreateSnackbar, { props: { modelValue: true }, }); const snack = wrapper.findComponent(VSnackbar); await snack.setValue(true); expect(snack.isVisible()).toBe(true); }); it('should close the snackbar when the undo button is clicked', async () => { const wrapper = mount(AnnotationCreateSnackbar, { props: { modelValue: true }, }); await wrapper.findComponent('button').trigger('click'); expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([false]); }); it('should close the snackbar when the close icon is clicked', async () => { const wrapper = mount(AnnotationCreateSnackbar, { props: { modelValue: true }, }); await wrapper.findComponent('[data-testid="closeBtn"]').trigger('click'); expect(wrapper.emitted('update:modelValue')?.[0]).toEqual([false]); }); });