tests for TransactionLink

This commit is contained in:
ogerly 2022-04-10 09:40:12 +02:00
parent 43863e21fc
commit 22aeb06f97
2 changed files with 10 additions and 9 deletions

View File

@ -24,8 +24,9 @@ const propsData = {
code: 'c00000000c000000c0000',
holdAvailableAmount: '5.13109484759482747111',
id: 12,
memo: 'Wie schön hier etwas Quatsch zu lesen!',
memo: 'Katzenauge, Eulenschrei, was verschwunden komm herbei!',
validUntil: '2022-03-30T14:22:40.000Z',
writeText: '',
}
describe('TransactionLink', () => {
@ -56,7 +57,7 @@ describe('TransactionLink', () => {
describe('copy with success', () => {
beforeEach(async () => {
navigatorClipboardMock.mockResolvedValue()
await wrapper.findAll('button').at(0).trigger('click')
await wrapper.find('.test-copy-link').trigger('click')
})
it('should call clipboard.writeText', () => {
expect(navigator.clipboard.writeText).toHaveBeenCalledWith(
@ -71,7 +72,7 @@ describe('TransactionLink', () => {
describe('copy with error', () => {
beforeEach(async () => {
navigatorClipboardMock.mockRejectedValue()
await wrapper.findAll('button').at(0).trigger('click')
await wrapper.find('.test-copy-link').trigger('click')
})
it('toasts error message', () => {
@ -92,7 +93,7 @@ describe('TransactionLink', () => {
spy = jest.spyOn(wrapper.vm.$bvModal, 'show')
// spy.mockImplementation(() => Promise.resolve('some value'))
// mockAPIcall.mockResolvedValue()
await wrapper.findAll('button').at(1).trigger('click')
await wrapper.find('.test-qr-code').trigger('click')
})
it('qr-code Modal if show', () => {
@ -113,7 +114,7 @@ describe('TransactionLink', () => {
spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
spy.mockImplementation(() => Promise.resolve('some value'))
mockAPIcall.mockResolvedValue()
await wrapper.findAll('button').at(2).trigger('click')
await wrapper.find('.test-delete-link').trigger('click')
})
it('test Modal if confirm true', () => {
@ -145,7 +146,7 @@ describe('TransactionLink', () => {
spy = jest.spyOn(wrapper.vm.$bvModal, 'msgBoxConfirm')
spy.mockImplementation(() => Promise.resolve('some value'))
mockAPIcall.mockRejectedValue({ message: 'Something went wrong :(' })
await wrapper.findAll('button').at(2).trigger('click')
await wrapper.find('.test-delete-link').trigger('click')
})
it('toasts an error message', () => {

View File

@ -15,7 +15,7 @@
<b-col lg="1" md="2" class="text-center text-lg-left qr-button">
<b-button
@click="$bvModal.show('modalPopover-' + id)"
class="p-2"
class="p-2 test-qr-code"
size="sm"
variant="outline-success"
>
@ -27,7 +27,7 @@
<b-col lg="1" md="1" class="text-center text-lg-right">
<b-button
class="p-2"
class="p-2 test-copy-link"
size="sm"
variant="outline-primary"
@click="copy"
@ -37,7 +37,7 @@
</b-button>
<br />
<b-button
class="p-2"
class="p-2 test-delete-link"
size="sm"
variant="outline-danger"
@click="deleteLink()"