diff --git a/frontend/src/components/Transaction.spec.js b/frontend/src/components/Transaction.spec.js index 43dc44782..67091c363 100644 --- a/frontend/src/components/Transaction.spec.js +++ b/frontend/src/components/Transaction.spec.js @@ -1,8 +1,55 @@ import { mount } from '@vue/test-utils' import Transaction from './Transaction' +import Vue from 'vue' + +// disable throwing Errors on warnings to catch the warning +Vue.config.warnHandler = (w) => { +} const localVue = global.localVue +const consoleError = console.error +const consoleErrorMock = jest.fn() +console.error = consoleErrorMock + + +/* + gdtEntries: [ + { + amount: 100, + gdt: 1700, + factor: 17, + comment: '', + date: '2021-05-02T17:20:11+00:00', + gdtEntryType: GdtEntryType.FORM, + }, + { + amount: 1810, + gdt: 362, + factor: 0.2, + comment: 'Dezember 20', + date: '2020-12-31T12:00:00+00:00', + gdtEntryType: GdtEntryType.GLOBAL_MODIFICATOR, + }, + { + amount: 100, + gdt: 1700, + factor: 17, + comment: '', + date: '2020-05-07T17:00:00+00:00', + gdtEntryType: GdtEntryType.FORM, + }, + { + amount: 100, + gdt: 110, + factor: 22, + comment: '', + date: '2020-04-10T13:28:00+00:00', + gdtEntryType: GdtEntryType.ELOPAGE_PUBLISHER, + }, + ], +*/ + describe('Transaction', () => { let wrapper @@ -27,5 +74,23 @@ describe('Transaction', () => { it('renders the component', () => { expect(wrapper.find('div.gdt-transaction-list-item').exists()).toBeTruthy() }) + + describe('no valid GDT entry type', () => { + beforeEach(async () => { + await wrapper.setProps({ gdtEntryType: 'NOT_VALID' }) + }) + + it('throws an error', () => { + expect(consoleErrorMock).toBeCalledWith(expect.objectContaining({ message: 'no lines for this type: NOT_VALID' })) + }) + }) + + describe('default entry type FORM', () => { + beforeEach((async () + it('has the heart icon', () => { + console.log(wrapper.html()) + expect(wrapper.vm.getLinesByType.icon).toBe('heart') + }) + }) }) }) diff --git a/frontend/src/components/Transaction.vue b/frontend/src/components/Transaction.vue index cc027306b..41bd54b42 100644 --- a/frontend/src/components/Transaction.vue +++ b/frontend/src/components/Transaction.vue @@ -5,8 +5,8 @@
@@ -20,10 +20,10 @@ - {{ getLinesByType(gdtEntryType).description }} + {{ getLinesByType.description }} - {{ getLinesByType(gdtEntryType).descriptiontext }} + {{ getLinesByType.descriptiontext }} @@ -33,7 +33,7 @@ {{ $t('gdt.credit') }} - {{ getLinesByType(gdtEntryType).credittext }} + {{ getLinesByType.credittext }} @@ -71,65 +71,63 @@