src/components/Transactions/TransactionLinksSummary.spec.js

This commit is contained in:
Moriz Wahl 2022-03-17 20:06:24 +01:00
parent b75330c142
commit b8d4366e46

View File

@ -5,7 +5,40 @@ import { toastErrorSpy } from '@test/testSetup'
const localVue = global.localVue const localVue = global.localVue
const apolloQueryMock = jest.fn().mockResolvedValue({ const apolloQueryMock = jest.fn()
const mocks = {
$i18n: {
locale: 'en',
},
$t: jest.fn((t) => t),
$tc: jest.fn((tc) => tc),
$apollo: {
query: apolloQueryMock,
},
}
const propsData = {
amount: '123',
decay: {
decay: '-0.2038314055482643084',
start: '2022-02-25T07:29:26.000Z',
end: '2022-02-28T13:55:47.000Z',
duration: 282381,
},
transactionLinkCount: 4,
}
describe('TransactionLinksSummary', () => {
let wrapper
const Wrapper = () => {
return mount(TransactionLinksSummary, { localVue, mocks, propsData })
}
describe('mount', () => {
beforeEach(() => {
apolloQueryMock.mockResolvedValue({
data: { data: {
listTransactionLinks: [ listTransactionLinks: [
{ {
@ -50,38 +83,8 @@ const apolloQueryMock = jest.fn().mockResolvedValue({
}, },
], ],
}, },
}) })
const mocks = {
$i18n: {
locale: 'en',
},
$t: jest.fn((t) => t),
$tc: jest.fn((tc) => tc),
$apollo: {
query: apolloQueryMock,
},
}
const propsData = {
amount: '123',
decay: {
decay: '-0.2038314055482643084',
start: '2022-02-25T07:29:26.000Z',
end: '2022-02-28T13:55:47.000Z',
duration: 282381,
},
transactionLinkCount: 4,
}
describe('TransactionLinksSummary', () => {
let wrapper
const Wrapper = () => {
return mount(TransactionLinksSummary, { localVue, mocks, propsData })
}
describe('mount', () => {
beforeEach(() => {
wrapper = Wrapper() wrapper = Wrapper()
}) })
@ -132,6 +135,10 @@ describe('TransactionLinksSummary', () => {
it('emits update transactions', () => { it('emits update transactions', () => {
expect(wrapper.emitted('update-transactions')).toBeTruthy() expect(wrapper.emitted('update-transactions')).toBeTruthy()
}) })
it('has four transaction links in list', () => {
expect(wrapper.vm.transactionLinks).toHaveLength(4)
})
}) })
describe('load more transaction links', () => { describe('load more transaction links', () => {