format tests

This commit is contained in:
antelle 2020-03-21 11:56:26 +01:00
parent 4f53e39f8d
commit b96b477f65
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,18 @@
import { expect } from 'chai';
import { DateFormat } from 'util/formatting/date-format';
describe('DateFormat', () => {
const dt = new Date(2020, 0, 2, 3, 4, 5, 6);
it('should format date', () => {
expect(DateFormat.dStr(dt)).to.eql('2 Jan 2020');
});
it('should format date and time', () => {
expect(DateFormat.dtStr(dt)).to.eql('2 Jan 2020 03:04:05');
});
it('should format date and time in sortable format', () => {
expect(DateFormat.dtStrFs(dt)).to.eql('2020-01-02T03-04-05');
});
});

View File

@ -0,0 +1,10 @@
import { expect } from 'chai';
import { IconUrlFormat } from 'util/formatting/icon-url-format';
describe('IconUrlFormat', () => {
it('should convert to dataurl', () => {
expect(IconUrlFormat.toDataUrl(new Uint8Array([1, 2]))).to.eql(
'data:image/png;base64,AQI='
);
});
});