mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
refactor tests GddTransactionList.spec.js
This commit is contained in:
parent
4ad268e86c
commit
8ef657c60e
@ -60,24 +60,24 @@ describe('GddTransactionList', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('without any properties', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.setProps({
|
||||
transactions: [],
|
||||
count: -1,
|
||||
})
|
||||
})
|
||||
it('renders text saying that there are error.empty-transactionlist ', () => {
|
||||
expect(wrapper.find('div.gdd-transaction-list').text()).toContain(
|
||||
'transaction.nullTransactions',
|
||||
)
|
||||
})
|
||||
it('renders text saying that there are no transaction.nullTransactions', () => {
|
||||
expect(wrapper.find('div.gdd-transaction-list').text()).toContain(
|
||||
'transaction.nullTransactions',
|
||||
)
|
||||
})
|
||||
})
|
||||
// describe.only('without any properties', () => {
|
||||
// beforeEach(async () => {
|
||||
// await wrapper.setProps({
|
||||
// transactions: [],
|
||||
// count: -1,
|
||||
// })
|
||||
// })
|
||||
// it('renders text saying that there are error.empty-transactionlist ', () => {
|
||||
// expect(wrapper.find('div.gdd-transaction-list').text()).toContain(
|
||||
// 'transaction.nullTransactions',
|
||||
// )
|
||||
// })
|
||||
// it('renders text saying that there are no transaction.nullTransactions', () => {
|
||||
// expect(wrapper.find('div.gdd-transaction-list').text()).toContain(
|
||||
// 'transaction.nullTransactions',
|
||||
// )
|
||||
// })
|
||||
// })
|
||||
|
||||
describe('timestamp property', () => {
|
||||
it('emits update-transactions when timestamp changes', async () => {
|
||||
@ -91,48 +91,98 @@ describe('GddTransactionList', () => {
|
||||
await wrapper.setProps({
|
||||
transactions: [
|
||||
{
|
||||
amount: 19.93,
|
||||
balanceDate: '2021-05-25T17:38:13+00:00',
|
||||
memo: 'Alles Gute zum Geburtstag',
|
||||
linkedUser: { firstName: 'Bob', lastName: 'der Baumeister' },
|
||||
id: 29,
|
||||
typeId: 'SEND',
|
||||
decay: { decay: '0.5' },
|
||||
},
|
||||
{
|
||||
amount: 1000,
|
||||
balanceDate: '2021-04-29T15:34:49+00:00',
|
||||
memo: 'Gut das du da bist!',
|
||||
linkedUser: { firstName: 'Gradido', lastName: 'Akademie' },
|
||||
id: 3,
|
||||
typeId: 'CREATION',
|
||||
},
|
||||
{
|
||||
amount: 314.98,
|
||||
balanceDate: '2021-04-29T17:26:40+00:00',
|
||||
memo: 'Für das Fahrrad!',
|
||||
linkedUser: { firstName: 'Jan', lastName: 'Ulrich' },
|
||||
id: 8,
|
||||
typeId: 'RECEIVE',
|
||||
decay: { decay: '1.5' },
|
||||
},
|
||||
{
|
||||
amount: 1.07,
|
||||
id: -1,
|
||||
typeId: 'DECAY',
|
||||
amount: '-0.16778637075575395772595',
|
||||
balance: '31.59320453982945549519405',
|
||||
balanceDate: '2022-03-03T08:54:54.020Z',
|
||||
memo: '',
|
||||
linkedUser: null,
|
||||
decay: {
|
||||
decay: '-0.16778637075575395772595',
|
||||
start: '2022-02-28T13:55:47.000Z',
|
||||
end: '2022-03-03T08:54:54.020Z',
|
||||
duration: 241147.02,
|
||||
__typename: 'Decay',
|
||||
},
|
||||
__typename: 'Transaction',
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
typeId: 'SEND',
|
||||
amount: '1',
|
||||
balance: '31.76099091058520945292',
|
||||
balanceDate: '2022-02-28T13:55:47.000Z',
|
||||
memo: 'adasd adada',
|
||||
linkedUser: {
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
__typename: 'User',
|
||||
},
|
||||
decay: {
|
||||
decay: '-0.2038314055482643084',
|
||||
start: '2022-02-25T07:29:26.000Z',
|
||||
end: '2022-02-28T13:55:47.000Z',
|
||||
duration: 282381,
|
||||
__typename: 'Decay',
|
||||
},
|
||||
__typename: 'Transaction',
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
typeId: 'CREATION',
|
||||
amount: '1000',
|
||||
balance: '32.96482231613347376132',
|
||||
balanceDate: '2022-02-25T07:29:26.000Z',
|
||||
memo: 'asd adada dad',
|
||||
linkedUser: {
|
||||
firstName: 'Gradido',
|
||||
lastName: 'Akademie',
|
||||
__typename: 'User',
|
||||
},
|
||||
decay: {
|
||||
decay: '-0.03517768386652623868',
|
||||
start: '2022-02-23T10:55:30.000Z',
|
||||
end: '2022-02-25T07:29:26.000Z',
|
||||
duration: 160436,
|
||||
__typename: 'Decay',
|
||||
},
|
||||
__typename: 'Transaction',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
typeId: 'RECEIVE',
|
||||
amount: '10',
|
||||
balance: '10',
|
||||
balanceDate: '2022-02-23T10:55:30.000Z',
|
||||
memo: 'asd adaaad adad addad ',
|
||||
linkedUser: {
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
__typename: 'User',
|
||||
},
|
||||
decay: {
|
||||
decay: '0',
|
||||
start: null,
|
||||
end: null,
|
||||
duration: null,
|
||||
__typename: 'Decay',
|
||||
},
|
||||
__typename: 'Transaction',
|
||||
},
|
||||
],
|
||||
transactionCount: 12,
|
||||
count: 12,
|
||||
})
|
||||
})
|
||||
|
||||
it('renders 4 transactions', () => {
|
||||
expect(wrapper.findAll('div.gdd-transaction-list-item')).toHaveLength(4)
|
||||
expect(wrapper.findAll('div.list-group-item')).toHaveLength(4)
|
||||
})
|
||||
|
||||
describe('send transactions', () => {
|
||||
describe('decay transactions', () => {
|
||||
let transaction
|
||||
beforeEach(() => {
|
||||
transaction = wrapper.findAll('div.gdd-transaction-list-item').at(0)
|
||||
transaction = wrapper.findAll('div.list-group-item').at(0)
|
||||
})
|
||||
|
||||
it('has a bi-caret-down-square icon', () => {
|
||||
@ -144,15 +194,41 @@ describe('GddTransactionList', () => {
|
||||
])
|
||||
})
|
||||
|
||||
// it('transaction is clicked', async () => {
|
||||
// await transaction.trigger('click')
|
||||
// expect(transaction.findAll('svg').at(0).classes()).toEqual([
|
||||
// 'bi-caret-up-square',
|
||||
// 'b-icon',
|
||||
// 'bi',
|
||||
// 'text-muted',
|
||||
// ])
|
||||
// })
|
||||
it('has a bi-droplet-half icon', () => {
|
||||
expect(transaction.findAll('svg').at(1).classes()).toContain('bi-droplet-half')
|
||||
})
|
||||
|
||||
it('has gradido-global-color-gray color', () => {
|
||||
expect(transaction.findAll('svg').at(1).classes()).toContain('gradido-global-color-gray')
|
||||
})
|
||||
|
||||
it('shows the amount of transaction', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-item-amount').at(0).text()).toContain(
|
||||
'-0.16778637075575395772595',
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the name of the receiver', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-item-name').at(0).text()).toBe(
|
||||
'decay.decay_since_last_transaction',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('send transactions', () => {
|
||||
let transaction
|
||||
beforeEach(() => {
|
||||
transaction = wrapper.findAll('div.list-group-item').at(1)
|
||||
})
|
||||
|
||||
it('has a bi-caret-down-square icon', () => {
|
||||
expect(transaction.findAll('svg').at(0).classes()).toEqual([
|
||||
'bi-caret-down-square',
|
||||
'b-icon',
|
||||
'bi',
|
||||
'text-muted',
|
||||
])
|
||||
})
|
||||
|
||||
it('has a bi-arrow-left-circle icon', () => {
|
||||
expect(transaction.findAll('svg').at(1).classes()).toContain('bi-arrow-left-circle')
|
||||
@ -164,45 +240,46 @@ describe('GddTransactionList', () => {
|
||||
|
||||
it('has a minus operator', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-item-operator').at(0).text()).toContain(
|
||||
'−',
|
||||
'-',
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the amount of transaction', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-item-amount').at(0).text()).toContain(
|
||||
'19.93',
|
||||
'1',
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the name of the receiver', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-item-name').at(0).text()).toContain(
|
||||
'Bob der Baumeister',
|
||||
'Bibi Bloxberg',
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the message of the transaction', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-message').at(0).text()).toContain(
|
||||
'Alles Gute zum Geburtstag',
|
||||
'adasd adada',
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the date of the transaction', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-item-date').at(0).text()).toContain(
|
||||
'Tue May 25 2021',
|
||||
'Mon Feb 28 2022 14:55:47 GMT+0100 (Mitteleuropäische Normalzeit)',
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the decay calculation', () => {
|
||||
expect(transaction.findAll('div.gdd-transaction-list-item-decay').at(0).text()).toContain(
|
||||
'− 0.5',
|
||||
'-0.2038314055482643084',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('creation transactions', () => {
|
||||
let transaction
|
||||
|
||||
beforeEach(() => {
|
||||
transaction = wrapper.findAll('div.gdd-transaction-list-item').at(1)
|
||||
transaction = wrapper.findAll('div.list-group-item').at(2)
|
||||
})
|
||||
|
||||
it('has a bi-caret-down-square icon', () => {
|
||||
@ -214,16 +291,6 @@ describe('GddTransactionList', () => {
|
||||
])
|
||||
})
|
||||
|
||||
// it('transaction is clicked', async () => {
|
||||
// await transaction.trigger('click')
|
||||
// expect(transaction.findAll('svg').at(0).classes()).toEqual([
|
||||
// 'bi-caret-up-square',
|
||||
// 'b-icon',
|
||||
// 'bi',
|
||||
// 'text-muted',
|
||||
// ])
|
||||
// })
|
||||
|
||||
it('has a bi-gift icon', () => {
|
||||
expect(transaction.findAll('svg').at(1).classes()).toContain('bi-gift')
|
||||
})
|
||||
@ -254,7 +321,7 @@ describe('GddTransactionList', () => {
|
||||
|
||||
it('shows the date of the transaction', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-item-date').at(0).text()).toContain(
|
||||
'Thu Apr 29 2021',
|
||||
'Fri Feb 25 2022 08:29:26 GMT+0100 (Mitteleuropäische Normalzeit)',
|
||||
)
|
||||
})
|
||||
})
|
||||
@ -262,7 +329,7 @@ describe('GddTransactionList', () => {
|
||||
describe('receive transactions', () => {
|
||||
let transaction
|
||||
beforeEach(() => {
|
||||
transaction = wrapper.findAll('div.gdd-transaction-list-item').at(2)
|
||||
transaction = wrapper.findAll('div.list-group-item').at(3)
|
||||
})
|
||||
|
||||
it('has a bi-caret-down-square icon', () => {
|
||||
@ -274,24 +341,19 @@ describe('GddTransactionList', () => {
|
||||
])
|
||||
})
|
||||
|
||||
// it('transaction is clicked', async () => {
|
||||
// await transaction.trigger('click')
|
||||
// expect(transaction.findAll('svg').at(0).classes()).toEqual([
|
||||
// 'bi-caret-up-square',
|
||||
// 'b-icon',
|
||||
// 'bi',
|
||||
// 'text-muted',
|
||||
// ])
|
||||
// })
|
||||
|
||||
it('has a bi-arrow-right-circle icon', () => {
|
||||
expect(transaction.findAll('svg').at(1).classes()).toContain('bi-arrow-right-circle')
|
||||
})
|
||||
|
||||
it('has gradido-global-color-accent color', () => {
|
||||
expect(transaction.findAll('svg').at(1).classes()).toContain(
|
||||
'gradido-global-color-accent',
|
||||
)
|
||||
it('has text-success color', () => {
|
||||
expect(transaction.findAll('svg').at(1).classes()).toEqual([
|
||||
'bi-arrow-right-circle',
|
||||
'text-success',
|
||||
'm-mb-1',
|
||||
'font2em',
|
||||
'b-icon',
|
||||
'bi',
|
||||
])
|
||||
})
|
||||
|
||||
it('has a plus operator', () => {
|
||||
@ -302,86 +364,37 @@ describe('GddTransactionList', () => {
|
||||
|
||||
it('shows the amount of transaction', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-item-amount').at(0).text()).toContain(
|
||||
'314.98',
|
||||
'10',
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the name of the recipient', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-item-name').at(0).text()).toContain(
|
||||
'Jan Ulrich',
|
||||
'Bibi Bloxberg',
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the message of the transaction', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-message').at(0).text()).toContain(
|
||||
'Für das Fahrrad!',
|
||||
'asd adaaad adad addad',
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the date of the transaction', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-item-date').at(0).text()).toContain(
|
||||
'Thu Apr 29 2021',
|
||||
'Wed Feb 23 2022 11:55:30 GMT+0100 (Mitteleuropäische Normalzeit)',
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the decay calculation', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-item-decay').at(0).text()).toContain(
|
||||
'− 1.5',
|
||||
'0',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('decay transactions', () => {
|
||||
let transaction
|
||||
beforeEach(() => {
|
||||
transaction = wrapper.findAll('div.gdd-transaction-list-item').at(3)
|
||||
})
|
||||
/*
|
||||
|
||||
it('has a bi-caret-down-square icon', () => {
|
||||
expect(transaction.findAll('svg').at(0).classes()).toEqual([
|
||||
'bi-caret-down-square',
|
||||
'b-icon',
|
||||
'bi',
|
||||
'text-muted',
|
||||
])
|
||||
})
|
||||
|
||||
// it('transaction is clicked', async () => {
|
||||
// await transaction.trigger('click')
|
||||
// expect(transaction.findAll('svg').at(0).classes()).toEqual([
|
||||
// 'bi-caret-up-square',
|
||||
// 'b-icon',
|
||||
// 'bi',
|
||||
// 'text-muted',
|
||||
// ])
|
||||
// })
|
||||
|
||||
it('has a bi-droplet-half icon', () => {
|
||||
expect(transaction.findAll('svg').at(1).classes()).toContain('bi-droplet-half')
|
||||
})
|
||||
|
||||
it('has gradido-global-color-gray color', () => {
|
||||
expect(transaction.findAll('svg').at(1).classes()).toContain('gradido-global-color-gray')
|
||||
})
|
||||
|
||||
it('has a minus operator', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-item-operator').at(0).text()).toContain(
|
||||
'−',
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the amount of transaction', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-item-amount').at(0).text()).toContain(
|
||||
'1.07',
|
||||
)
|
||||
})
|
||||
|
||||
it('shows the name of the receiver', () => {
|
||||
expect(transaction.findAll('.gdd-transaction-list-item-name').at(0).text()).toBe(
|
||||
'decay.decay_since_last_transaction',
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('with invalid transaction type', () => {
|
||||
@ -389,12 +402,25 @@ describe('GddTransactionList', () => {
|
||||
await wrapper.setProps({
|
||||
transactions: [
|
||||
{
|
||||
balance: '19.93',
|
||||
date: '2021-05-25T17:38:13+00:00',
|
||||
memo: 'Alles Gute zum Geburtstag',
|
||||
name: 'Bob der Baumeister',
|
||||
transaction_id: 29,
|
||||
type: 'invalid',
|
||||
id: 9,
|
||||
typeId: 'invalid',
|
||||
amount: '1',
|
||||
balance: '31.76099091058520945292',
|
||||
balanceDate: '2022-02-28T13:55:47.000Z',
|
||||
memo: 'adasd adada',
|
||||
linkedUser: {
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
__typename: 'User',
|
||||
},
|
||||
decay: {
|
||||
decay: '-0.2038314055482643084',
|
||||
start: '2022-02-25T07:29:26.000Z',
|
||||
end: '2022-02-28T13:55:47.000Z',
|
||||
duration: 282381,
|
||||
__typename: 'Decay',
|
||||
},
|
||||
__typename: 'Transaction',
|
||||
},
|
||||
],
|
||||
})
|
||||
@ -404,16 +430,21 @@ describe('GddTransactionList', () => {
|
||||
expect(errorHandler).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
describe('pagination buttons', () => {
|
||||
const transactions = Array.from({ length: 42 }, (_, idx) => {
|
||||
return {
|
||||
balance: '3.14',
|
||||
date: '2021-04-29T17:26:40+00:00',
|
||||
amount: '3.14',
|
||||
balanceDate: '2021-04-29T17:26:40+00:00',
|
||||
memo: 'Kreiszahl PI',
|
||||
name: 'Euklid',
|
||||
transaction_id: idx + 1,
|
||||
type: 'receive',
|
||||
linkedUser: {
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
__typename: 'User',
|
||||
},
|
||||
id: idx + 1,
|
||||
typeId: 'RECEIVE',
|
||||
}
|
||||
})
|
||||
|
||||
@ -472,6 +503,7 @@ describe('GddTransactionList', () => {
|
||||
])
|
||||
expect(scrollToMock).toBeCalled()
|
||||
})
|
||||
*/
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user