import * as R from 'ramda';
import { assert } from 'chai';

import * as RA from '../src';

describe('toInteger32', function () {
  context('given a small integer', function () {
    specify('should maintain the same value', function () {
      assert.strictEqual(RA.toInteger32(1), 1);
    });

    specify('should preserve the sign', function () {
      assert.strictEqual(RA.toInteger32(-1), -1);
    });
  });

  context('given an integer 23^2 + 1', function () {
    specify('should return 1', function () {
      const initialValue = 2 ** 32 + 1;
      assert.strictEqual(RA.toInteger32(initialValue), 1);
    });
  });

  context('given an integer 23^2 - 1', function () {
    specify('should return -1', function () {
      const initialValue = 2 ** 32 - 1;
      assert.strictEqual(RA.toInteger32(initialValue), -1);
    });
  });

  context('given invalid input', function () {
    specify('should return 0', function () {
      assert.strictEqual(RA.toInteger32(false), 0);
      assert.strictEqual(RA.toInteger32([]), 0);
      assert.strictEqual(RA.toInteger32(null), 0);
      assert.strictEqual(RA.toInteger32(NaN), 0);
      assert.strictEqual(RA.toInteger32(/a/), 0);
      assert.strictEqual(RA.toInteger32({}), 0);
      assert.strictEqual(RA.toInteger32(new Error()), 0);
    });
  });

  context('given Infinity value', function () {
    specify('should return 0', function () {
      assert.strictEqual(RA.toInteger32(Infinity), 0);
      assert.strictEqual(RA.toInteger32(-Infinity), 0);
    });
  });

  it('should support placeholder to specify "gaps"', function () {
    const toInteger32 = RA.toInteger32(R.__);

    assert.strictEqual(toInteger32(1.2), 1);
  });

  describe('toInt32', function () {
    it('should be alias of seq', function () {
      assert.strictEqual(RA.toInt32, RA.toInteger32);
    });
  });
});

@@ -1683,19 +1683,21 @@
 ;%0A  %7D);%0A
-%0A  
+%7D);%0A%0A
 describe
@@ -1722,18 +1722,16 @@
 on () %7B%0A
-  
   it('sh
@@ -1751,11 +1751,19 @@
  of 
-seq
+toInteger32
 ', f
@@ -1767,34 +1767,32 @@
 , function () %7B%0A
-  
     assert.stric
@@ -1827,24 +1827,16 @@
 ger32);%0A
-    %7D);%0A
   %7D);%0A%7D)

fix alias testing