update test

This commit is contained in:
Moriz Wahl 2022-04-20 09:15:08 +02:00
parent ff652fa72e
commit 0b53cfa044
2 changed files with 107 additions and 86 deletions

View File

@ -100,6 +100,11 @@ describe('TransactionLinkSummary', () => {
expect(wrapper.findComponent({ name: 'CollapseLinksList' }).exists()).toBe(true) expect(wrapper.findComponent({ name: 'CollapseLinksList' }).exists()).toBe(true)
}) })
describe('click on transaction links', () => {
beforeEach(() => {
wrapper.find('div.transaction-link-details').trigger('click')
})
it('calls the API to get the list transaction links', () => { it('calls the API to get the list transaction links', () => {
expect(apolloQueryMock).toBeCalledWith({ expect(apolloQueryMock).toBeCalledWith({
query: listTransactionLinks, query: listTransactionLinks,
@ -114,32 +119,18 @@ describe('TransactionLinkSummary', () => {
expect(wrapper.vm.transactionLinks).toHaveLength(4) expect(wrapper.vm.transactionLinks).toHaveLength(4)
}) })
describe('reset transaction links', () => { describe('close transaction link details', () => {
beforeEach(async () => { beforeEach(() => {
jest.clearAllMocks() jest.clearAllMocks()
await wrapper.setData({ wrapper.find('div.transaction-link-details').trigger('click')
currentPage: 0,
pending: false,
pageSize: 5,
})
}) })
it('reloads transaction links', () => { it('does not call the API', () => {
expect(apolloQueryMock).toBeCalledWith({ expect(apolloQueryMock).not.toBeCalled()
query: listTransactionLinks,
variables: {
currentPage: 1,
},
fetchPolicy: 'network-only',
})
}) })
it('emits update transactions', () => { it('has no component CollapseLinksList', () => {
expect(wrapper.emitted('update-transactions')).toBeTruthy() expect(wrapper.findComponent({ name: 'CollapseLinksList' }).isVisible()).toBe(false)
})
it('has four transaction links in list', () => {
expect(wrapper.vm.transactionLinks).toHaveLength(4)
}) })
}) })
@ -216,11 +207,41 @@ describe('TransactionLinkSummary', () => {
}) })
}) })
}) })
})
describe('reset transaction links', () => {
beforeEach(async () => {
jest.clearAllMocks()
await wrapper.setData({
currentPage: 0,
pending: false,
pageSize: 5,
})
})
it('reloads transaction links', () => {
expect(apolloQueryMock).toBeCalledWith({
query: listTransactionLinks,
variables: {
currentPage: 1,
},
fetchPolicy: 'network-only',
})
})
it('emits update transactions', () => {
expect(wrapper.emitted('update-transactions')).toBeTruthy()
})
it('has four transaction links in list', () => {
expect(wrapper.vm.transactionLinks).toHaveLength(4)
})
})
describe('loads transaction links with error', () => { describe('loads transaction links with error', () => {
beforeEach(() => { beforeEach(() => {
apolloQueryMock.mockRejectedValue({ message: 'OUCH!' }) apolloQueryMock.mockRejectedValue({ message: 'OUCH!' })
wrapper = Wrapper() wrapper.find('div.transaction-link-details').trigger('click')
}) })
it('toasts an error message', () => { it('toasts an error message', () => {

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="transaction-slot-link gradido-shadow-inset"> <div class="transaction-slot-link gradido-shadow-inset">
<div> <div>
<div @click="showTransactionLinks()"> <div class="transaction-link-details" @click="showTransactionLinks()">
<!-- Collaps Icon --> <!-- Collaps Icon -->
<collapse-icon class="text-right" :visible="visible" /> <collapse-icon class="text-right" :visible="visible" />
<div> <div>