diff --git a/frontend/src/components/TransactionRows/AmountAndNameRow.spec.js b/frontend/src/components/TransactionRows/AmountAndNameRow.spec.js new file mode 100644 index 000000000..d221d46f0 --- /dev/null +++ b/frontend/src/components/TransactionRows/AmountAndNameRow.spec.js @@ -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') + }) + }) + }) +}) diff --git a/frontend/src/components/TransactionRows/AmountAndNameRow.vue b/frontend/src/components/TransactionRows/AmountAndNameRow.vue index fd54b2761..0fa82efe9 100644 --- a/frontend/src/components/TransactionRows/AmountAndNameRow.vue +++ b/frontend/src/components/TransactionRows/AmountAndNameRow.vue @@ -10,7 +10,11 @@
- + {{ itemText }} {{ itemText }}