Commit 3abc26c4 authored by Evgeny's avatar Evgeny

Clean code. Improve tests

parent 158e2835
import dataFormatter from 'excel-style-dataformatter';
// Default Excel value
const decimalPlaces = 2;
const locale = 'ru-RU';
export default function format(v, type='', str=''){
if(type === '' && str === ''){
return basicFormat(v);
......
......@@ -30,4 +30,18 @@ describe('format', ()=>{
expect(format(1.1234, 'Number', str)).to.be('1,12р.');
expect(format(1.1289, 'Number', str)).to.be('1,13р.');
});
it('should do date formatting', ()=>{
let d = new Date(2016, 0, 1, 0, 0, 0, 0);
expect(format(d, 'DateTime', 'yyyy-mm-dd')).to.be('2016-01-01');
d = new Date(2016, 0, 1, 1, 0, 0, 0);
expect(format(d, 'DateTime', 'hh:mm')).to.be('01:00');
d = new Date(2016, 0, 1, 1, 59, 0, 0);
expect(format(d, 'DateTime', 'hh:mm')).to.be('01:59');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment