diff --git a/admin/src/components/Tables/SearchUserTable.vue b/admin/src/components/Tables/SearchUserTable.vue index 024001193..0be24a099 100644 --- a/admin/src/components/Tables/SearchUserTable.vue +++ b/admin/src/components/Tables/SearchUserTable.vue @@ -49,30 +49,40 @@ - - {{ $t('userIsDeleted') }} - - - - - + + + + + + + + + + + + + + + + + diff --git a/admin/src/components/TransactionLinkList.vue b/admin/src/components/TransactionLinkList.vue index fa67c8797..0289792a2 100644 --- a/admin/src/components/TransactionLinkList.vue +++ b/admin/src/components/TransactionLinkList.vue @@ -1,7 +1,7 @@ - {{ $t('transactionlink.form_header') }} + {{ $t('transactionlink.name') }} { $t: jest.fn((t) => t), $n: jest.fn((n) => n), $d: jest.fn((d) => d), - $apollo: { - query: apolloMock, - }, + } + + const propsData = { + transactionsGdt: [], + transactionGdtCount: 0, + pageSize: 25, + value: 1, } const Wrapper = () => { - return mount(GdtTransactionList, { localVue, mocks }) + return mount(GdtTransactionList, { localVue, mocks, propsData }) } - describe('mount - When no transactions are loaded', () => { + describe('transactionGdtCount is 0', () => { beforeEach(() => { wrapper = Wrapper() }) @@ -62,54 +51,50 @@ describe('GdtTransactionList ', () => { }) }) - 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, - }, - ], - }, - }, - }) + describe('Transactions are loaded', () => { + beforeEach(async () => { wrapper = Wrapper() + await wrapper.setProps({ + transactionGdtCount: 42, + transactionsGdt: [ + { + 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, + }, + ], + }) }) it('renders the component', () => { @@ -120,83 +105,25 @@ describe('GdtTransactionList ', () => { expect(wrapper.find('.gdt-funding').exists()).toBe(false) }) - describe('server returns valid data', () => { - it('calls the API', async () => { - await wrapper.vm.$nextTick() - expect(apolloMock).toBeCalledWith( - expect.objectContaining({ - variables: { - currentPage: 1, - pageSize: 25, - }, - }), - ) - }) - - it('scrolls to (0, 0) after API call', () => { - expect(windowScrollToMock).toBeCalledWith(0, 0) - }) - }) - - describe('server returns error', () => { - beforeEach(() => { - jest.resetAllMocks() - apolloMock.mockRejectedValue({ - message: 'Ouch!', - }) - wrapper = Wrapper() - }) - - it('toasts an error message', () => { - expect(toastErrorSpy).toBeCalledWith('Ouch!') - }) - }) - describe('change of currentPage', () => { it('calls the API after currentPage changes', async () => { jest.clearAllMocks() - await wrapper.setData({ transactionGdtCount: 42 }) await wrapper.findComponent({ name: 'BPagination' }).vm.$emit('input', 2) - expect(apolloMock).toBeCalledWith( - expect.objectContaining({ - variables: { - currentPage: 2, - pageSize: 25, - }, - }), - ) + expect(wrapper.emitted('input')).toEqual([[2]]) }) describe('pagination buttons', () => { describe('with transactionCount > pageSize', () => { - beforeEach(async () => { - apolloMock.mockResolvedValue({ - data: { - listGDTEntries: { - count: 42, - gdtEntries: [], - }, - }, - }) - wrapper = Wrapper() - }) - it('shows the pagination buttons', () => { expect(wrapper.find('ul.pagination').exists()).toBe(true) }) }) describe('with transactionCount < pageSize', () => { - beforeEach(async () => { - apolloMock.mockResolvedValue({ - data: { - listGDTEntries: { - count: 2, - gdtEntries: [], - }, - }, + beforeEach(() => { + wrapper.setProps({ + transactionGdtCount: 10, }) - wrapper = Wrapper() }) it('shows no pagination buttons', () => { @@ -205,5 +132,17 @@ describe('GdtTransactionList ', () => { }) }) }) + + describe('server not reachable', () => { + beforeEach(() => { + wrapper.setProps({ + transactionGdtCount: -1, + }) + }) + + it('renders the not-reachable text', () => { + expect(wrapper.text()).toBe('gdt.not-reachable') + }) + }) }) }) diff --git a/frontend/src/components/GdtTransactionList.vue b/frontend/src/components/GdtTransactionList.vue index 8944ea69b..4934f9fce 100644 --- a/frontend/src/components/GdtTransactionList.vue +++ b/frontend/src/components/GdtTransactionList.vue @@ -8,7 +8,7 @@ {{ $t('gdt.funding') }} - + {{ $t('gdt.not-reachable') }}