Merge pull request #624 from gradido/test-up-transaction-list

feat: Test UserProfileTransactionList
This commit is contained in:
Moriz Wahl 2021-07-13 14:39:20 +02:00 committed by GitHub
commit 8ddec8e067
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,41 @@
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('emits update-transactions after creation', () => {
expect(wrapper.emitted('update-transactions')).toEqual(
expect.arrayContaining([expect.arrayContaining([{ firstPage: 1, items: 25 }])]),
)
})
it('emist update-transactions when update-transactions is called', () => {
wrapper
.findComponent({ name: 'GddTransactionList' })
.vm.$emit('update-transactions', { firstPage: 2, items: 25 })
expect(wrapper.emitted('update-transactions')).toEqual(
expect.arrayContaining([expect.arrayContaining([{ firstPage: 2, items: 25 }])]),
)
})
})
})

View File

@ -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 },
},