I am writing a test for a component that has the Primevue Dropdown. I am trying to write a test to determine if an event has emitted when a value is selected in the dropdown.
I am using Vitest (0.23.0) and Vue/Test Utils (2.0.2).
I have the following so far:
Code: Select all
it('emits selectedDay event when day is selected', () => {
const wrapper = mount(DayAndTimePicker, {
props: {},
global: {
plugins: [PrimeVue, ConfirmationService, DialogService, ToastService],
},
})
// find the dropdown and click on the dropdown so that the options appear
const openDropdown = wrapper.find('.p-dropdown-label')
await openDropdown.trigger('click')
// from this point onwards, I am trying to find any of the options in the DOM and click on them but can't seem to find them
const dropdownOption = wrapper.get('.p-dropdown-item')
expect(wrapper.emitted()).toHaveProperty('selectedDay')
})
Appreciate any guidance on the matter