From b689440fafd05c9375fd1ac19d2383986c212e76 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 26 May 2021 13:13:30 +0200 Subject: [PATCH 1/7] setup tests for transaction list --- .../GddTransactionList.spec.js | 84 +++++++++++++++++++ .../AccountOverview/GddTransactionList.vue | 23 ++--- 2 files changed, 92 insertions(+), 15 deletions(-) create mode 100644 frontend/src/views/Pages/AccountOverview/GddTransactionList.spec.js diff --git a/frontend/src/views/Pages/AccountOverview/GddTransactionList.spec.js b/frontend/src/views/Pages/AccountOverview/GddTransactionList.spec.js new file mode 100644 index 000000000..753543019 --- /dev/null +++ b/frontend/src/views/Pages/AccountOverview/GddTransactionList.spec.js @@ -0,0 +1,84 @@ +import { mount } from '@vue/test-utils' +import GddTransactionList from './GddTransactionList' + +const localVue = global.localVue + +describe('GddTransactionList', () => { + let wrapper + + const mocks = { + $n: jest.fn((n) => n), + $t: jest.fn((t) => t), + $moment: jest.fn((m) => m), + } + + const Wrapper = () => { + return mount(GddTransactionList, { localVue, mocks }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the component', () => { + expect(wrapper.find('div.gdd-transaction-list').exists()).toBeTruthy() + }) + + describe('without any properties', () => { + it('renders text saying that there are no transactions', () => { + expect(wrapper.find('div.gdd-transaction-list').text()).toBe('transaction.nullTransactions') + }) + }) + + describe('timestamp property', () => { + it('emits update-transactions when timestamp changes', async () => { + await wrapper.setProps({ timestamp: 0 }) + expect(wrapper.emitted('update-transactions')).toBeTruthy() + }) + }) + + describe('with transacrions', () => { + beforeEach(async () => { + await wrapper.setProps({ + transactions: [ + { + balance: '19.93', + date: '2021-05-25T17:38:13+00:00', + memo: 'Alles Gute zum Geburtstag', + name: 'Bob der Baumeister', + transaction_id: 29, + type: 'send', + }, + { + balance: '1000', + date: '2021-04-29T15:34:49+00:00', + memo: 'Gut das du da bist!', + name: 'Gradido Akademie', + transaction_id: 3, + type: 'creation', + }, + { + balance: '314.98', + date: '2021-04-29T17:26:40+00:00', + memo: 'Für das Fahrrad!', + name: 'Jan Ulrich', + transaction_id: 8, + type: 'receive', + }, + { + balance: '1.07', + type: 'decay', + }, + ], + transactionCount: 12, + }) + }) + + it('renders 4 transactions', () => { + console.log(wrapper.html()) + expect(true).toBeThruthy() + }) + }) + }) +}) diff --git a/frontend/src/views/Pages/AccountOverview/GddTransactionList.vue b/frontend/src/views/Pages/AccountOverview/GddTransactionList.vue index 7fae1d935..9875e62cc 100644 --- a/frontend/src/views/Pages/AccountOverview/GddTransactionList.vue +++ b/frontend/src/views/Pages/AccountOverview/GddTransactionList.vue @@ -1,5 +1,5 @@