From 28b871f11bc3f367bd13709dc9d9a24a4ec8de2b Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 9 Sep 2021 09:05:38 +0200 Subject: [PATCH] fix review, fix more tests in transaction.spec and transactionCollaps --- frontend/src/components/Transaction.spec.js | 31 ++++++++++++---- frontend/src/components/Transaction.vue | 2 +- .../components/TransactionCollapse.spec.js | 36 +++++++++++++------ .../src/components/TransactionCollapse.vue | 4 +-- frontend/src/locales/de.json | 12 +------ frontend/src/locales/en.json | 14 ++------ 6 files changed, 56 insertions(+), 43 deletions(-) diff --git a/frontend/src/components/Transaction.spec.js b/frontend/src/components/Transaction.spec.js index d78af1e76..5bb704de6 100644 --- a/frontend/src/components/Transaction.spec.js +++ b/frontend/src/components/Transaction.spec.js @@ -3,8 +3,6 @@ import Transaction from './Transaction' const localVue = global.localVue -const toastErrorMock = jest.fn() - describe('Transaction', () => { let wrapper @@ -15,16 +13,13 @@ describe('Transaction', () => { $t: jest.fn((t) => t), $n: jest.fn((n) => n), $d: jest.fn((d) => d), - $toasted: { - error: toastErrorMock, - }, } const propsData = { amount: 100, gdt: 110, factor: 22, - comment: '', + comment: 'this is the comment for a gdt transaction', date: '2020-04-10T13:28:00+00:00', gdtEntryType: 4, } @@ -41,5 +36,29 @@ describe('Transaction', () => { it('renders the component', () => { expect(wrapper.find('div.gdt-transaction-list-item').exists()).toBeTruthy() }) + + it('checks the prop amount ', () => { + expect(wrapper.props().amount).toBe(100) + }) + + it('checks the prop gdt ', () => { + expect(wrapper.props().gdt).toBe(110) + }) + + it('checks the prop factor ', () => { + expect(wrapper.props().factor).toBe(22) + }) + + it('checks the prop comment ', () => { + expect(wrapper.props().comment).toBe('this is the comment for a gdt transaction') + }) + + it('checks the prop date ', () => { + expect(wrapper.props().date).toBe('2020-04-10T13:28:00+00:00') + }) + + it('checks the prop gdtEntryType ', () => { + expect(wrapper.props().gdtEntryType).toBe(4) + }) }) }) diff --git a/frontend/src/components/Transaction.vue b/frontend/src/components/Transaction.vue index ce5b225d9..39a62b878 100644 --- a/frontend/src/components/Transaction.vue +++ b/frontend/src/components/Transaction.vue @@ -115,7 +115,7 @@ export default { const type = linesByType[givenType] if (type) return type - throw new Error('no lines for this type') + throw new Error('no lines for this type: ' + givenType) }, }, } diff --git a/frontend/src/components/TransactionCollapse.spec.js b/frontend/src/components/TransactionCollapse.spec.js index a4345dec0..5e3207c57 100644 --- a/frontend/src/components/TransactionCollapse.spec.js +++ b/frontend/src/components/TransactionCollapse.spec.js @@ -3,25 +3,23 @@ import TransactionCollapse from './TransactionCollapse' const localVue = global.localVue -const toastErrorMock = jest.fn() - describe('TransactionCollapse', () => { let wrapper const mocks = { - $i18n: { - locale: 'en', - }, $t: jest.fn((t) => t), $n: jest.fn((n) => n), - $d: jest.fn((d) => d), - $toasted: { - error: toastErrorMock, - }, + } + + const propsData = { + amount: 100, + gdt: 110, + factor: 22, + gdtEntryType: 4, } const Wrapper = () => { - return mount(TransactionCollapse, { localVue, mocks }) + return mount(TransactionCollapse, { localVue, mocks, propsData }) } describe('mount', () => { @@ -30,7 +28,23 @@ describe('TransactionCollapse', () => { }) it('renders the component', () => { - expect(wrapper.find('div.gdt-transaction-collaps').exists()).toBeTruthy() + expect(wrapper.find('div.gdt-transaction-collapse').exists()).toBeTruthy() + }) + + it('checks the prop amount ', () => { + expect(wrapper.props().amount).toBe(100) + }) + + it('checks the prop gdt ', () => { + expect(wrapper.props().gdt).toBe(110) + }) + + it('checks the prop factor ', () => { + expect(wrapper.props().factor).toBe(22) + }) + + it('checks the prop gdtEntryType ', () => { + expect(wrapper.props().gdtEntryType).toBe(4) }) }) }) diff --git a/frontend/src/components/TransactionCollapse.vue b/frontend/src/components/TransactionCollapse.vue index 6d6acfdc5..d36165785 100644 --- a/frontend/src/components/TransactionCollapse.vue +++ b/frontend/src/components/TransactionCollapse.vue @@ -1,5 +1,5 @@