test link to send with param email

This commit is contained in:
Moriz Wahl 2022-03-21 21:09:00 +01:00
parent ec354eafad
commit f0132593b8
2 changed files with 66 additions and 1 deletions

View File

@ -0,0 +1,61 @@
import { mount } from '@vue/test-utils'
import AmountAndNameRow from './AmountAndNameRow'
const localVue = global.localVue
const mocks = {}
const propsData = {
amount: '19.99',
text: 'Some text',
}
describe('AmountAndNameRow', () => {
let wrapper
const Wrapper = () => {
return mount(AmountAndNameRow, { localVue, mocks, propsData })
}
describe('mount', () => {
beforeEach(() => {
wrapper = Wrapper()
})
it('renders the component', () => {
expect(wrapper.find('div.amount-and-name-row').exists()).toBe(true)
})
describe('without linked user', () => {
it('has a span with the text', () => {
expect(wrapper.find('div.gdd-transaction-list-item-name').text()).toBe('Some text')
})
it('has no link', () => {
expect(wrapper.find('div.gdd-transaction-list-item-name').find('a').exists()).toBe(false)
})
})
describe('with linked user', () => {
beforeEach(async () => {
await wrapper.setProps({
linkedUser: { firstName: 'Bibi', lastName: 'Bloxberg', email: 'bibi@bloxberg.de' },
})
})
it('has a link with first and last name', () => {
expect(wrapper.find('div.gdd-transaction-list-item-name').text()).toBe('Bibi Bloxberg')
})
it('has a link', () => {
expect(wrapper.find('div.gdd-transaction-list-item-name').find('a').exists()).toBe(true)
})
it('links with param email', () => {
expect(
wrapper.find('div.gdd-transaction-list-item-name').find('a').attributes('href'),
).toBe('/send?email=bibi@bloxberg.de')
})
})
})
})

View File

@ -10,7 +10,11 @@
</b-col>
<b-col cols="7">
<div class="gdd-transaction-list-item-name">
<b-link v-if="linkedUser" :href="`/send?email=${linkedUser.email}`" @click.stop>
<b-link
v-if="linkedUser && linkedUser.email"
:href="`/send?email=${linkedUser.email}`"
@click.stop
>
{{ itemText }}
</b-link>
<span v-else>{{ itemText }}</span>