import { expect } from 'chai';
import { round, abs } from '../src/utils';

describe('utils', () => {

  describe('bitwise Math.round', () => {

    it('rounds 5.5 to 6', () => {
      expect(round(5.5)).to.equal(6);
    });

    it('rounds 173.2 to 173', () => {
      expect(round(173.2)).to.equal(173);
    });

    it('rounds 9238422.8734282342 to 9238423', () => {
      expect(round(9238422.8734282342)).to.equal(9238423);
    });

    it('rounds 0 to 0', () => {
      expect(round(0)).to.equal(0);
    });

    it('rounds -0 to 0', () => {
      expect(round(-0)).to.equal(0);
    });

    it('rounds undefined to 0', () => {
      expect(round(undefined)).to.equal(0);
    });

    it('rounds null to 0', () => {
      expect(round(null)).to.equal(0);
    });

  });

  describe('bitwise Math.abs', () => {

    it('absolute equals 82736 from 82736.091283913401034', () => {
      expect(abs(82736.091283913401034)).to.equal(82736);
    });

    it('absolute equals 82736 from -82736.091283913401034', () => {
      expect(abs(-82736.091283913401034)).to.equal(82736);
    });

    it('absolute equals 0 from 0', () => {
      expect(abs(0)).to.equal(0);
    });

    it('absolute equals 0 from -0', () => {
      expect(abs(-0)).to.equal(0);
    });

    it('absolute equals 0 from undefined', () => {
      expect(round(undefined)).to.equal(0);
    });

    it('absolute equals 0 from null', () => {
      expect(round(null)).to.equal(0);
    });

  });

});

@@ -43,16 +43,26 @@
 und, abs
+, polarize
  %7D from 
@@ -823,33 +823,24 @@
  %7B%0A%0A    it('
-absolute 
 equals 82736
@@ -948,33 +948,24 @@
 );%0A%0A    it('
-absolute 
 equals 82736
@@ -1075,33 +1075,24 @@
 );%0A%0A    it('
-absolute 
 equals 0 fro
@@ -1152,33 +1152,24 @@
 );%0A%0A    it('
-absolute 
 equals 0 fro
@@ -1231,33 +1231,24 @@
 );%0A%0A    it('
-absolute 
 equals 0 fro
@@ -1334,17 +1334,8 @@
 it('
-absolute 
 equa
@@ -1381,34 +1381,535 @@
 ound(null)).
+to.equal(0);%0A    %7D);%0A%0A  %7D);%0A%0A  describe('polarize pixels', () =%3E %7B%0A%0A    it('5 to equal 255 at threshold 10', () =%3E %7B%0A      expect(polarize(5, 10));%0A    %7D)%0A%0A    it('5 to equal 0 at threshold 1', () =%3E %7B%0A      expect(polarize(5, 1));%0A    %7D)%0A%0A    it('0 to equal 0 at threshold 10', () =%3E %7B%0A      expect(polarize(0, 10));%0A    %7D)%0A%0A    it('null to equal 255 at threshold 10', () =%3E %7B%0A      expect(polarize(null, 10));%0A    %7D)%0A%0A    it('undefined 
 to
-.
+ 
 equal
-(0
+ 0 at threshold -0', () =%3E %7B%0A      expect(polarize(undefined, -0)
 );%0A    %7D);%0A%0A
@@ -1897,30 +1897,29 @@
 ed, -0));%0A    %7D)
-;
 %0A%0A  %7D);%0A%0A%7D);%0A

Add polarize tests.