From db6cea4cbdb03e077962808af8d7c41574ff660a Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Fri, 22 Oct 2021 08:58:37 +0200 Subject: [PATCH] only one describe block on top level --- .../GdtTransactionList.spec.js | 125 +++++++----------- 1 file changed, 51 insertions(+), 74 deletions(-) diff --git a/frontend/src/views/Pages/AccountOverview/GdtTransactionList.spec.js b/frontend/src/views/Pages/AccountOverview/GdtTransactionList.spec.js index 359260db1..77507cb69 100644 --- a/frontend/src/views/Pages/AccountOverview/GdtTransactionList.spec.js +++ b/frontend/src/views/Pages/AccountOverview/GdtTransactionList.spec.js @@ -4,7 +4,7 @@ import GdtTransactionList from './GdtTransactionList' const localVue = global.localVue -const apolloMockNull = jest.fn().mockResolvedValue({ +const apolloMock = jest.fn().mockResolvedValue({ data: { listGDTEntries: { count: 0, @@ -13,48 +13,6 @@ const apolloMockNull = jest.fn().mockResolvedValue({ }, }) -const apolloMock = jest.fn().mockResolvedValue({ - data: { - listGDTEntries: { - count: 4, - 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, - }, - ], - }, - }, -}) - const toastErrorMock = jest.fn() const windowScrollToMock = jest.fn() @@ -82,7 +40,7 @@ describe('GdtTransactionList ', () => { error: toastErrorMock, }, $apollo: { - query: apolloMockNull, + query: apolloMock, }, } @@ -100,40 +58,59 @@ describe('GdtTransactionList ', () => { }) it('links to https://gradido.net/en/memberships/ when clicking', async () => { - const link = 'https://gradido.net/' + state.language + '/memberships/' - expect(wrapper.find('.gdt-funding').attributes('href')).toBe(link) + expect(wrapper.find('.gdt-funding').attributes('href')).toBe( + 'https://gradido.net/' + state.language + '/memberships/', + ) }) }) -}) - -describe('GdtTransactionList', () => { - let wrapper - - const mocks = { - $store: { - state, - commit: jest.fn(), - }, - $i18n: { - locale: 'en', - }, - $t: jest.fn((t) => t), - $n: jest.fn((n) => n), - $d: jest.fn((d) => d), - $toasted: { - error: toastErrorMock, - }, - $apollo: { - query: apolloMock, - }, - } - - const Wrapper = () => { - return mount(GdtTransactionList, { localVue, mocks }) - } describe('mount - When transactions are loaded', () => { beforeEach(() => { + apolloMock.mockResolvedValue({ + data: { + listGDTEntries: { + count: 4, + gdtEntries: [ + { + id: 1, + amount: 100, + gdt: 1700, + factor: 17, + comment: '', + date: '2021-05-02T17:20:11+00:00', + gdtEntryType: GdtEntryType.FORM, + }, + { + id: 2, + amount: 1810, + gdt: 362, + factor: 0.2, + comment: 'Dezember 20', + date: '2020-12-31T12:00:00+00:00', + gdtEntryType: GdtEntryType.GLOBAL_MODIFICATOR, + }, + { + id: 3, + amount: 100, + gdt: 1700, + factor: 17, + comment: '', + date: '2020-05-07T17:00:00+00:00', + gdtEntryType: GdtEntryType.FORM, + }, + { + id: 4, + amount: 100, + gdt: 110, + factor: 22, + comment: '', + date: '2020-04-10T13:28:00+00:00', + gdtEntryType: GdtEntryType.ELOPAGE_PUBLISHER, + }, + ], + }, + }, + }) wrapper = Wrapper() }) @@ -141,7 +118,7 @@ describe('GdtTransactionList', () => { expect(wrapper.find('div.gdt-transaction-list').exists()).toBeTruthy() }) - it('renders the not funding button ', () => { + it('does not render the funding button ', () => { expect(wrapper.find('.gdt-funding').exists()).toBe(false) })