add tests
This commit is contained in:
23
src/formaters.spec.ts
Normal file
23
src/formaters.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { describe, expect, test } from 'vitest'
|
||||||
|
import { formatEveDate, formatIsk } from './formaters'
|
||||||
|
|
||||||
|
describe('formatIsk', () => {
|
||||||
|
test('Formats ISK correctly', () => {
|
||||||
|
expect(formatIsk(123456789)).toBe('123.456.789,00 ISK')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('formatEveDate', () => {
|
||||||
|
test('Formats EVE date correctly', () => {
|
||||||
|
const date = new Date(Date.UTC(2022, 0, 1, 0, 0))
|
||||||
|
expect(formatEveDate(date)).toBe('2022.1.1 0:0')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('Returns empty string for undefined date', () => {
|
||||||
|
expect(formatEveDate()).toBe('')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('Returns empty string for null date', () => {
|
||||||
|
expect(formatEveDate(null)).toBe('')
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -11,4 +11,4 @@ export const percentFormater = new Intl.NumberFormat("en-US", {
|
|||||||
maximumFractionDigits: 0
|
maximumFractionDigits: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
export const formatEveDate = (date?: Date) => !date ? '' : `${date.getUTCFullYear()}.${date.getUTCMonth() + 1}.${date.getUTCDate()} ${date.getUTCHours()}:${date.getUTCMinutes()}`;
|
export const formatEveDate = (date?: Date | null) => !date ? '' : `${date.getUTCFullYear()}.${date.getUTCMonth() + 1}.${date.getUTCDate()} ${date.getUTCHours()}:${date.getUTCMinutes()}`;
|
||||||
Reference in New Issue
Block a user