mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add tests for amount filters
This commit is contained in:
parent
938b811d8a
commit
acba22040c
@ -12,6 +12,7 @@ const amount = (value) => {
|
|||||||
|
|
||||||
const GDD = (value) => {
|
const GDD = (value) => {
|
||||||
value = amount(value)
|
value = amount(value)
|
||||||
|
if (value === '') return ''
|
||||||
if (!value.match(/^− /)) value = '+ ' + value
|
if (!value.match(/^− /)) value = '+ ' + value
|
||||||
return value + ' GDD'
|
return value + ' GDD'
|
||||||
}
|
}
|
||||||
|
|||||||
35
frontend/src/filters/amount.test.js
Normal file
35
frontend/src/filters/amount.test.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import { loadFilters } from './amount'
|
||||||
|
|
||||||
|
const i18nMock = {
|
||||||
|
n: jest.fn((n) => n),
|
||||||
|
}
|
||||||
|
|
||||||
|
const { amount, GDD } = loadFilters(i18nMock)
|
||||||
|
|
||||||
|
describe('amount', () => {
|
||||||
|
it('returns empty string when called with null', () => {
|
||||||
|
expect(amount(null)).toBe('')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns 0 when called with 0', () => {
|
||||||
|
expect(amount(0)).toBe('0')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns a leading proper minus sign when called with negative value', () => {
|
||||||
|
expect(amount(-1)).toBe('− 1')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('GDD', () => {
|
||||||
|
it('returns empty string when called with null', () => {
|
||||||
|
expect(GDD(null)).toBe('')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns "+ 0 GDD" when called with 0', () => {
|
||||||
|
expect(GDD(0)).toBe('+ 0 GDD')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns a leading proper minus sign when called with negative value', () => {
|
||||||
|
expect(GDD(-1)).toBe('− 1 GDD')
|
||||||
|
})
|
||||||
|
})
|
||||||
Loading…
x
Reference in New Issue
Block a user