mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add unit tests for copying a created transaction link with username, amount and memo text
This commit is contained in:
parent
21c9bc22a7
commit
d1cc3115ba
@ -20,9 +20,6 @@ describe('Send', () => {
|
||||
balance: 123.45,
|
||||
GdtBalance: 1234.56,
|
||||
pending: true,
|
||||
amount: '15',
|
||||
link: 'http://localhost/redeem/0123456789',
|
||||
memo: 'Quis auctor elit sed vulputate mi sit amet mauris commodo quis imperdiet.',
|
||||
}
|
||||
|
||||
const mocks = {
|
||||
@ -260,6 +257,46 @@ describe('Send', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('copy link and text with success', () => {
|
||||
const navigatorClipboard = navigator.clipboard
|
||||
beforeAll(() => {
|
||||
delete navigator.clipboard
|
||||
navigator.clipboard = { writeText: navigatorClipboardMock }
|
||||
})
|
||||
afterAll(() => {
|
||||
navigator.clipboard = navigatorClipboard
|
||||
})
|
||||
|
||||
describe('copy link and text with success', () => {
|
||||
beforeEach(async () => {
|
||||
navigatorClipboardMock.mockResolvedValue()
|
||||
await wrapper.findAll('button').at(0).trigger('click')
|
||||
})
|
||||
|
||||
it('should call clipboard.writeText', () => {
|
||||
expect(navigator.clipboard.writeText).toHaveBeenCalledWith(
|
||||
'http://localhost/redeem/0123456789\n' +
|
||||
'Testy transaction-link.send_you 56.78 Gradido.\n' +
|
||||
'"Make the best of the link!"',
|
||||
)
|
||||
})
|
||||
it('toasts success message', () => {
|
||||
expect(toastSuccessSpy).toBeCalledWith('gdd_per_link.link-and-text-copied')
|
||||
})
|
||||
})
|
||||
|
||||
describe('copy link and text with error', () => {
|
||||
beforeEach(async () => {
|
||||
navigatorClipboardMock.mockRejectedValue()
|
||||
await wrapper.findAll('button').at(0).trigger('click')
|
||||
})
|
||||
|
||||
it('toasts error message', () => {
|
||||
expect(toastErrorSpy).toBeCalledWith('gdd_per_link.not-copied')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('close button click', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.findAll('button').at(3).trigger('click')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user