From e56ba22dcb2eb7afcd4ef34ed33cd1712e939567 Mon Sep 17 00:00:00 2001 From: ogerly Date: Mon, 13 Sep 2021 11:08:06 +0200 Subject: [PATCH] tests for all gdtEntryTypes --- .../components/TransactionCollapse.spec.js | 112 ++++++++++++++++-- .../src/components/TransactionCollapse.vue | 4 +- 2 files changed, 103 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/TransactionCollapse.spec.js b/frontend/src/components/TransactionCollapse.spec.js index 66f73fcd9..a263a2878 100644 --- a/frontend/src/components/TransactionCollapse.spec.js +++ b/frontend/src/components/TransactionCollapse.spec.js @@ -11,26 +11,30 @@ describe('TransactionCollapse', () => { $n: jest.fn((n) => n), } - const propsData = { - amount: 100, - gdt: 110, - factor: 22, - gdtEntryType: 1, - } - - const Wrapper = () => { + const Wrapper = (propsData) => { return mount(TransactionCollapse, { localVue, mocks, propsData }) } - describe('mount', () => { + describe('mount with gdtEntryType: 1', () => { beforeEach(() => { - wrapper = Wrapper() + const propsData = { + amount: 100, + gdt: 110, + factor: 22, + gdtEntryType: 1, + } + + wrapper = Wrapper(propsData) }) it('renders the component', () => { expect(wrapper.find('div.gdt-transaction-collapse').exists()).toBeTruthy() }) + it('checks the prop gdtEntryType ', () => { + expect(wrapper.props().gdtEntryType).toBe(1) + }) + it('renders the component clooaps-header', () => { expect(wrapper.find('.gdt-list-clooaps-header-text')).toBeTruthy() }) @@ -54,9 +58,95 @@ describe('TransactionCollapse', () => { it('renders the component clooaps-secondMath', () => { expect(wrapper.find('#clooaps-secondMath').text()).toBe('100 € * 22 GDT / € = 110 GDT') }) + }) + + describe('mount with gdtEntryType: 7', () => { + beforeEach(() => { + const propsData = { + amount: 100, + gdt: 2200, + factor: 22, + gdtEntryType: 7, + } + + wrapper = Wrapper(propsData) + }) + + it('renders the component', () => { + expect(wrapper.find('div.gdt-transaction-collapse').exists()).toBeTruthy() + }) it('checks the prop gdtEntryType ', () => { - expect(wrapper.props().gdtEntryType).toBe(1) + expect(wrapper.props().gdtEntryType).toBe(7) + }) + + it('renders the component clooaps-header', () => { + expect(wrapper.find('.gdt-list-clooaps-header-text')).toBeTruthy() + }) + + it('renders the component clooaps-headline', () => { + expect(wrapper.find('#clooaps-headline').text()).toBe('gdt.conversion-gdt-euro') + }) + + it('renders the component clooaps-first', () => { + expect(wrapper.find('#clooaps-first').text()).toBe('gdt.raise') + }) + + it('renders the component clooaps-second', () => { + expect(wrapper.find('#clooaps-second').text()).toBe('gdt.conversion') + }) + + it('renders the component clooaps-firstMath', () => { + expect(wrapper.find('#clooaps-firstMath').text()).toBe('2200 %') + }) + + it('renders the component clooaps-secondMath', () => { + expect(wrapper.find('#clooaps-secondMath').text()).toBe('100 GDT * 2200 % = 2200 GDT') + }) + }) + + describe('mount with gdtEntryType: 4', () => { + beforeEach(() => { + const propsData = { + amount: 100, + gdt: 2200, + factor: 22, + gdtEntryType: 4, + } + + wrapper = Wrapper(propsData) + }) + + it('renders the component', () => { + expect(wrapper.find('div.gdt-transaction-collapse').exists()).toBeTruthy() + }) + + it('checks the prop gdtEntryType ', () => { + expect(wrapper.props().gdtEntryType).toBe(4) + }) + + it('renders the component clooaps-header', () => { + expect(wrapper.find('.gdt-list-clooaps-header-text')).toBeTruthy() + }) + + it('renders the component clooaps-headline', () => { + expect(wrapper.find('#clooaps-headline').text()).toBe('gdt.publisher') + }) + + it('renders the component clooaps-first', () => { + expect(wrapper.find('#clooaps-first').text()).toBe('') + }) + + it('renders the component clooaps-second', () => { + expect(wrapper.find('#clooaps-second').text()).toBe('') + }) + + it('renders the component clooaps-firstMath', () => { + expect(wrapper.find('#clooaps-firstMath').text()).toBe('') + }) + + it('renders the component clooaps-secondMath', () => { + expect(wrapper.find('#clooaps-secondMath').text()).toBe('') }) }) }) diff --git a/frontend/src/components/TransactionCollapse.vue b/frontend/src/components/TransactionCollapse.vue index 2f0955f04..7e92bace6 100644 --- a/frontend/src/components/TransactionCollapse.vue +++ b/frontend/src/components/TransactionCollapse.vue @@ -58,9 +58,9 @@ export default { second: this.$t('gdt.conversion'), secondMath: this.$n(this.amount, 'decimal') + - ' GDT * ' + + ' GDT * ' + this.factor * 100 + - '% = ' + + ' % = ' + this.$n(this.gdt, 'decimal') + ' GDT', },