-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6077 from m-kutnik/master
fix: missing default labels in ConfirmDialog and ConfirmPopup
- Loading branch information
Showing
4 changed files
with
151 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import PrimeVue from 'primevue/config'; | ||
import ConfirmPopup from './ConfirmPopup.vue'; | ||
|
||
describe('ConfirmPopup', () => { | ||
it('should exist', async () => { | ||
const wrapper = mount(ConfirmPopup, { | ||
global: { | ||
plugins: [PrimeVue], | ||
stubs: { | ||
teleport: true, | ||
transition: false | ||
} | ||
}, | ||
data() { | ||
return { | ||
confirmation: { | ||
message: 'Are you sure you want to proceed?', | ||
icon: 'pi pi-exclamation-triangle' | ||
}, | ||
visible: true | ||
}; | ||
} | ||
}); | ||
|
||
await wrapper.vm.$nextTick(); | ||
|
||
expect(wrapper.find('[role="alertdialog"]').isVisible()).toBe(true); | ||
expect(wrapper.find('.p-confirmpopup-message').text()).toBe('Are you sure you want to proceed?'); | ||
expect(wrapper.find('.p-confirmpopup-accept-button').text()).toBe('Yes'); | ||
expect(wrapper.find('.p-confirmpopup-reject-button').text()).toBe('No'); | ||
}); | ||
|
||
it('should dialog trigger the accept function', async () => { | ||
const wrapper = mount(ConfirmPopup, { | ||
global: { | ||
plugins: [PrimeVue], | ||
stubs: { | ||
teleport: true, | ||
transition: false | ||
} | ||
}, | ||
data() { | ||
return { | ||
confirmation: { | ||
message: 'Are you sure you want to proceed?', | ||
icon: 'pi pi-exclamation-triangle', | ||
accept: () => {}, | ||
reject: () => {} | ||
}, | ||
visible: true | ||
}; | ||
} | ||
}); | ||
|
||
await wrapper.vm.$nextTick(); | ||
|
||
const acceptTriggered = vi.spyOn(wrapper.componentVM.confirmation, 'accept'); | ||
const CDAcceptBtn = wrapper.find('.p-confirmpopup-accept-button'); | ||
|
||
await CDAcceptBtn.trigger('click'); | ||
|
||
expect(acceptTriggered).toBeCalled(); | ||
}); | ||
|
||
it('should dialog trigger the reject function', async () => { | ||
const wrapper = mount(ConfirmPopup, { | ||
global: { | ||
plugins: [PrimeVue], | ||
stubs: { | ||
teleport: true, | ||
transition: false | ||
} | ||
}, | ||
data() { | ||
return { | ||
confirmation: { | ||
message: 'Are you sure you want to proceed?', | ||
icon: 'pi pi-exclamation-triangle', | ||
accept: () => {}, | ||
reject: () => {} | ||
}, | ||
visible: true | ||
}; | ||
} | ||
}); | ||
|
||
await wrapper.vm.$nextTick(); | ||
|
||
const rejectTriggered = vi.spyOn(wrapper.componentVM.confirmation, 'reject'); | ||
const CDRejectBtn = wrapper.find('.p-confirmpopup-reject-button'); | ||
|
||
await CDRejectBtn.trigger('click'); | ||
|
||
expect(rejectTriggered).toBeCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters