From c3457b409b06dbe1aa427f3f4082dc4523c1656b Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 12 Jul 2021 11:11:54 +0200 Subject: [PATCH] feat: Test UserProfileTransactionList --- .../Pages/UserProfileTransactionList.spec.js | 33 +++++++++++++++++++ .../Pages/UserProfileTransactionList.vue | 3 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 frontend/src/views/Pages/UserProfileTransactionList.spec.js diff --git a/frontend/src/views/Pages/UserProfileTransactionList.spec.js b/frontend/src/views/Pages/UserProfileTransactionList.spec.js new file mode 100644 index 000000000..b075b2381 --- /dev/null +++ b/frontend/src/views/Pages/UserProfileTransactionList.spec.js @@ -0,0 +1,33 @@ +import { mount } from '@vue/test-utils' +import UserProfileTransactionList from './UserProfileTransactionList' + +const localVue = global.localVue + +describe('UserProfileTransactionList', () => { + let wrapper + + const mocks = { + $t: jest.fn((t) => t), + } + + const Wrapper = () => { + return mount(UserProfileTransactionList, { localVue, mocks }) + } + + describe('mount', () => { + beforeEach(() => { + wrapper = Wrapper() + }) + + it('renders the transaction table', () => { + expect(wrapper.findComponent({ name: 'GddTransactionList' }).exists()).toBeTruthy() + }) + + it('emist update-transactions when update-transactions is called', async () => { + wrapper.findComponent({ name: 'GddTransactionList' }).vm.$emit('update-transactions') + expect(wrapper.emitted('update-transactions')).toEqual( + expect.arrayContaining([expect.arrayContaining([{ firstPage: 1, items: 25 }])]), + ) + }) + }) +}) diff --git a/frontend/src/views/Pages/UserProfileTransactionList.vue b/frontend/src/views/Pages/UserProfileTransactionList.vue index f1896acc7..e6a25b436 100644 --- a/frontend/src/views/Pages/UserProfileTransactionList.vue +++ b/frontend/src/views/Pages/UserProfileTransactionList.vue @@ -19,12 +19,13 @@ import GddTransactionList from './AccountOverview/GddTransactionList.vue' export default { + name: 'UserProfileTransactionList', components: { GddTransactionList, }, props: { transactions: { - default: [], + default: () => [], }, transactionCount: { type: Number, default: 0 }, },