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

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

describe('thenCatchP', function() {
  context('given fulfilled Promise', function() {
    specify('should call "onFulfilled" callback', async function() {
      const promise = RA.resolveP(1);
      const expected = await RA.thenCatchP(
        R.add(1),
        R.always('danger!'),
        promise
      );

      assert.strictEqual(expected, 2);
    });
  });

  context('given rejected Promise', function() {
    specify('should call "onRejected" callback', async function() {
      const promise = RA.rejectP('a');
      const expected = await RA.thenCatchP(
        R.add(1),
        R.always('danger!'),
        promise
      );

      assert.strictEqual(expected, 'danger!');
    });
  });

  it('should curry', async function() {
    const promise = RA.resolveP(1);
    assert.strictEqual(
      await RA.thenCatchP(R.add(1), R.always('a'), promise),
      2
    );
    assert.strictEqual(
      await RA.thenCatchP(R.add(1), R.always('a'))(promise),
      2
    );
    assert.strictEqual(
      await RA.thenCatchP(R.add(1))(R.always('a'))(promise),
      2
    );
  });
});

@@ -111,24 +111,25 @@
 P', function
+ 
 () %7B%0A  conte
@@ -158,32 +158,33 @@
 omise', function
+ 
 () %7B%0A    specify
@@ -228,32 +228,33 @@
 , async function
+ 
 () %7B%0A      const
@@ -487,32 +487,33 @@
 omise', function
+ 
 () %7B%0A    specify
@@ -556,32 +556,33 @@
 , async function
+ 
 () %7B%0A      const
@@ -788,16 +788,16 @@
 %0A  %7D);%0A%0A
-
   it('sh
@@ -823,16 +823,17 @@
 function
+ 
 () %7B%0A   

fix linting issues