var formatter = require('../src/formatter');

describe('formatter', function () {
  it('should format numbers', function () {
    expect(formatter.formatNumber(0)).toBe(0);
    expect(formatter.formatNumber(0.001)).toBe('0.00100');
    expect(formatter.formatNumber(0.071)).toBe('0.0710');
    expect(formatter.formatNumber(0.71)).toBe('0.710');
    expect(formatter.formatNumber(-0.71)).toBe('-0.710');
    expect(formatter.formatNumber(5)).toBe('5');
    expect(formatter.formatNumber(5.0)).toBe('5');
    expect(formatter.formatNumber(5.00)).toBe('5');
    expect(formatter.formatNumber(5.71)).toBe('5.71');
    expect(formatter.formatNumber(-5.71)).toBe('-5.71');
    expect(formatter.formatNumber(186.7)).toBe('187');
    expect(formatter.formatNumber(96.7)).toBe('96.7');
    expect(formatter.formatNumber(500)).toBe('500');
    expect(formatter.formatNumber(1234)).toBe('1.2k');
  });

  it('shouldn\'t format non numbers', function () {
    expect(formatter.formatNumber(null)).toBe(null);
    expect(formatter.formatNumber('I am not a number')).toBe('I am not a number');
  });

  it('should format timestamps correctly', function () {
    var timestamp = 1494066976; // 2017-05-06 10:36:16
    expect(formatter.timestampFactory('year')(timestamp)).toEqual('2017');
    expect(formatter.timestampFactory('quarter')(timestamp)).toEqual('Q2 2017');
    expect(formatter.timestampFactory('month')(timestamp)).toEqual('May 2017');
    expect(formatter.timestampFactory('week')(timestamp)).toEqual('6th May 2017');
    expect(formatter.timestampFactory('day')(timestamp)).toEqual('6th May 2017');
    expect(formatter.timestampFactory('minute')(timestamp)).toEqual('10:36 05/06/2017');
  });
});

@@ -75,16 +75,70 @@
 on () %7B%0A
+  var timestamp = 1494066976; // 2017-05-06 10:36:16%0A%0A
   it('sh
@@ -1127,32 +1127,77 @@
 umber');%0A  %7D);%0A%0A
+  describe('without offset', function () %7B%0A  
   it('should for
@@ -1243,61 +1243,8 @@
 %7B%0A  
-  var timestamp = 1494066976; // 2017-05-06 10:36:16%0A
     
@@ -1283,16 +1283,19 @@
 y('year'
+, 0
 )(timest
@@ -1309,32 +1309,34 @@
 oEqual('2017');%0A
+  
     expect(forma
@@ -1366,16 +1366,19 @@
 quarter'
+, 0
 )(timest
@@ -1395,32 +1395,34 @@
 ual('Q2 2017');%0A
+  
     expect(forma
@@ -1450,16 +1450,19 @@
 ('month'
+, 0
 )(timest
@@ -1480,32 +1480,34 @@
 al('May 2017');%0A
+  
     expect(forma
@@ -1534,16 +1534,19 @@
 y('week'
+, 0
 )(timest
@@ -1568,32 +1568,34 @@
 6th May 2017');%0A
+  
     expect(forma
@@ -1621,16 +1621,19 @@
 ry('day'
+, 0
 )(timest
@@ -1659,24 +1659,26 @@
 May 2017');%0A
+  
     expect(f
@@ -1711,16 +1711,19 @@
 'minute'
+, 0
 )(timest
@@ -1753,22 +1753,241 @@
 /06/2017');%0A
+    %7D);%0A  %7D);%0A%0A  describe('with offset', function () %7B%0A    it('should format timestamps correctly', function () %7B%0A      expect(formatter.timestampFactory('minute', 3600)(timestamp)).toEqual('11:36 05/06/2017');%0A    %7D);%0A
   %7D);%0A%7D);%0A

fix tests