mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 23:57:12 +01:00
Added jest testing.
This commit is contained in:
parent
2363b03d1c
commit
2a8437cac9
5 changed files with 1338 additions and 23 deletions
38
src/lib/__tests__/format.test.ts
Normal file
38
src/lib/__tests__/format.test.ts
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import * as format from '../format';
|
||||
|
||||
test('parseTime', () => {
|
||||
expect(format.parseTime(86400 + 3600 + 60 + 1)).toEqual({
|
||||
days: 1,
|
||||
hours: 1,
|
||||
minutes: 1,
|
||||
seconds: 1,
|
||||
ms: 0,
|
||||
});
|
||||
});
|
||||
|
||||
test('formatTime', () => {
|
||||
expect(format.formatTime(3600 + 60 + 1)).toBe('1:01:01');
|
||||
});
|
||||
|
||||
test('formatShortTime', () => {
|
||||
expect(format.formatShortTime(3600 + 60 + 1)).toBe('1m1s');
|
||||
|
||||
expect(format.formatShortTime(3600 + 60 + 1, ['h', 'm', 's'])).toBe('1h1m1s');
|
||||
});
|
||||
|
||||
test('formatNumber', () => {
|
||||
expect(format.formatNumber('10.2')).toBe('10');
|
||||
expect(format.formatNumber('10.5')).toBe('11');
|
||||
});
|
||||
|
||||
test('formatLongNumber', () => {
|
||||
expect(format.formatLongNumber(1200000)).toBe('1.2m');
|
||||
expect(format.formatLongNumber(575000)).toBe('575k');
|
||||
expect(format.formatLongNumber(10500)).toBe('10.5k');
|
||||
expect(format.formatLongNumber(1200)).toBe('1.20k');
|
||||
});
|
||||
|
||||
test('stringToColor', () => {
|
||||
expect(format.stringToColor('hello')).toBe('#d218e9');
|
||||
expect(format.stringToColor('goodbye')).toBe('#11e956');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue