fix bugs in Transacrion Components, fix tests for GDD transaction list, use filter in menu and status

This commit is contained in:
Moriz Wahl 2022-03-08 06:21:36 +01:00
parent f58d1a843b
commit 0538b78cd1
6 changed files with 22 additions and 30 deletions

View File

@ -21,7 +21,6 @@ const mocks = {
isAdmin: true,
},
},
$n: jest.fn((n) => n),
}
describe('Navbar', () => {

View File

@ -10,7 +10,7 @@
</div>
<b-navbar-nav class="ml-auto" is-nav>
<b-nav-item>{{ pending ? '—' : $n(balance, 'decimal') }} GDD</b-nav-item>
<b-nav-item>{{ pending ? '—' : balance | amount }} GDD</b-nav-item>
<b-nav-item to="/profile" right class="d-none d-sm-none d-md-none d-lg-flex shadow-lg">
<small>
{{ $store.state.firstName }} {{ $store.state.lastName }},

View File

@ -1,7 +1,7 @@
<template>
<div class="gdd-status">
<div class="p-0 gdd-status-div">
{{ pending || balance === null ? '—' : $n(balance, 'decimal') }} {{ statusText }}
{{ pending || balance === null ? '—' : balance | amount }} {{ statusText }}
</div>
</div>
</template>

View File

@ -30,7 +30,7 @@
</b-col>
<b-col cols="7">
<div class="gdd-transaction-list-item-name">
{{ $t('decay.decay_since_last_transaction') }}
{{ linkedUser.firstName + ' ' + linkedUser.lastName }}
</div>
</b-col>
</b-row>

View File

@ -6,12 +6,11 @@ export const loadFilters = (_i18n) => {
}
const amount = (value) => {
if (!value) return ''
if (!value && value !== 0) return ''
return i18n.n(value.toString(), 'decimal').replace('-', ' ')
}
const GDD = (value) => {
if (!value) return ''
value = amount(value)
if (!value.match(/^ /)) value = '+ ' + value
return value + ' GDD'

View File

@ -88,6 +88,7 @@ describe('GddTransactionList', () => {
describe('with transactions', () => {
beforeEach(async () => {
const decayStartBlock = new Date(2001, 8, 9)
await wrapper.setProps({
transactions: [
{
@ -103,9 +104,7 @@ describe('GddTransactionList', () => {
start: '2022-02-28T13:55:47.000Z',
end: '2022-03-03T08:54:54.020Z',
duration: 241147.02,
__typename: 'Decay',
},
__typename: 'Transaction',
},
{
id: 9,
@ -117,16 +116,13 @@ describe('GddTransactionList', () => {
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,
@ -138,16 +134,13 @@ describe('GddTransactionList', () => {
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,
@ -159,24 +152,22 @@ describe('GddTransactionList', () => {
linkedUser: {
firstName: 'Bibi',
lastName: 'Bloxberg',
__typename: 'User',
},
decay: {
decay: '0',
start: null,
end: null,
duration: null,
__typename: 'Decay',
},
__typename: 'Transaction',
},
],
count: 12,
decayStartBlock,
})
})
it('renders 4 transactions', () => {
expect(wrapper.findAll('div.list-group-item')).toHaveLength(3)
expect(wrapper.findAll('div.list-group-item')).toHaveLength(4)
})
describe('decay transactions', () => {
@ -238,11 +229,12 @@ describe('GddTransactionList', () => {
expect(transaction.findAll('svg').at(1).classes()).toContain('text-danger')
})
// it('has a minus operator', () => {
// expect(transaction.findAll('.gdd-transaction-list-item-operator').at(0).text()).toContain(
// '-',
// )
// })
// operators are renderd by GDD filter
it.skip('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(
@ -293,7 +285,7 @@ describe('GddTransactionList', () => {
it('has a bi-gift icon', () => {
expect(transaction.findAll('svg').at(1).classes()).toEqual([
'bi-arrow-right-circle',
'bi-gift',
'gradido-global-color-accent',
'm-mb-1',
'font2em',
@ -308,7 +300,8 @@ describe('GddTransactionList', () => {
)
})
it('has a plus operator', () => {
// operators are renderd by GDD filter
it.skip('has a plus operator', () => {
expect(transaction.findAll('.gdd-transaction-list-item-operator').at(0).text()).toContain(
'+',
)
@ -316,19 +309,19 @@ describe('GddTransactionList', () => {
it('shows the amount of transaction', () => {
expect(transaction.findAll('.gdd-transaction-list-item-amount').at(0).text()).toContain(
'10',
'1000',
)
})
it('shows the name of the receiver', () => {
expect(transaction.findAll('.gdd-transaction-list-item-name').at(0).text()).toContain(
'Bibi Bloxberg',
'Gradido Akademie',
)
})
it('shows the date of the transaction', () => {
expect(transaction.findAll('.gdd-transaction-list-item-date').at(0).text()).toContain(
'Wed Feb 23 2022 10:55:30 GMT+0000 (Coordinated Universal Time)',
'Fri Feb 25 2022 07:29:26 GMT+0000 (Coordinated Universal Time)',
)
})
})
@ -336,7 +329,7 @@ describe('GddTransactionList', () => {
describe('receive transactions', () => {
let transaction
beforeEach(() => {
transaction = wrapper.findAll('div.list-group-item').at(2)
transaction = wrapper.findAll('div.list-group-item').at(3)
})
it('has a bi-caret-down-square icon', () => {
@ -363,7 +356,8 @@ describe('GddTransactionList', () => {
])
})
it('has a plus operator', () => {
// operators are renderd by GDD filter
it.skip('has a plus operator', () => {
expect(transaction.findAll('.gdd-transaction-list-item-operator').at(0).text()).toContain(
'+',
)