<commit_before>import { assert } from 'chai';

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

describe('allP', function() {
  context('given no arguments', function() {
    specify('should return reference to itself', function() {
      assert.strictEqual(RA.allP(), RA.allP);
    });
  });

  it('should resolve list of thenable values', function(done) {
    const p1 = RA.resolveP(1);
    const p2 = RA.resolveP(2);

    assert.eventually.deepEqual(RA.allP([p1, p2]), [1, 2]).notify(done);
  });

  it('should resolve list of mixed thenable and non-thenable values', function(done) {
    const p1 = RA.resolveP(1);
    const p2 = 2;

    assert.eventually.deepEqual(RA.allP([p1, p2]), [1, 2]).notify(done);
  });

  it('should resolve list of rejected thenable values', function(done) {
    const p1 = RA.resolveP(1);
    const p2 = RA.rejectP(2);

    assert.isRejected(RA.allP([p1, p2]), 2).notify(done);
  });

  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all#Promise.all_fail-fast_behaviour
  it('should have fail-fast behavior', function(done) {
    const p1 = new Promise(resolve => {
      setTimeout(resolve, 10, 'one');
    });
    const p2 = new Promise(resolve => {
      setTimeout(resolve, 20, 'two');
    });
    const p3 = new Promise(resolve => {
      setTimeout(resolve, 30, 'three');
    });
    const p4 = new Promise(resolve => {
      setTimeout(resolve, 40, 'four');
    });
    const p5 = new Promise((resolve, reject) => {
      reject(new Error());
    });

    assert.isRejected(RA.allP([p1, p2, p3, p4, p5]), Error).notify(done);
  });

  context('given there are two rejections', function() {
    specify('should reject with the first one', function(done) {
      const p1 = RA.resolveP(1);
      const p2 = RA.rejectP(1);
      const p3 = RA.rejectP(2);

      assert.isRejected(RA.allP([p1, p2, p3]), 1).notify(done);
    });
  });
});<commit_msg>test(allP): test support for ramda placeholder<commit_after>import { assert } from 'chai';
import * as R from 'ramda';

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

describe('allP', function() {
  context('given no arguments', function() {
    specify('should return reference to itself', function() {
      assert.strictEqual(RA.allP(), RA.allP);
    });
  });

  it('should resolve list of thenable values', function(done) {
    const p1 = RA.resolveP(1);
    const p2 = RA.resolveP(2);

    assert.eventually.deepEqual(RA.allP([p1, p2]), [1, 2]).notify(done);
  });

  it('should resolve list of mixed thenable and non-thenable values', function(done) {
    const p1 = RA.resolveP(1);
    const p2 = 2;

    assert.eventually.deepEqual(RA.allP([p1, p2]), [1, 2]).notify(done);
  });

  it('should resolve list of rejected thenable values', function(done) {
    const p1 = RA.resolveP(1);
    const p2 = RA.rejectP(2);

    assert.isRejected(RA.allP([p1, p2]), 2).notify(done);
  });

  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all#Promise.all_fail-fast_behaviour
  it('should have fail-fast behavior', function(done) {
    const p1 = new Promise(resolve => {
      setTimeout(resolve, 10, 'one');
    });
    const p2 = new Promise(resolve => {
      setTimeout(resolve, 20, 'two');
    });
    const p3 = new Promise(resolve => {
      setTimeout(resolve, 30, 'three');
    });
    const p4 = new Promise(resolve => {
      setTimeout(resolve, 40, 'four');
    });
    const p5 = new Promise((resolve, reject) => {
      reject(new Error());
    });

    assert.isRejected(RA.allP([p1, p2, p3, p4, p5]), Error).notify(done);
  });

  context('given there are two rejections', function() {
    specify('should reject with the first one', function(done) {
      const p1 = RA.resolveP(1);
      const p2 = RA.rejectP(1);
      const p3 = RA.rejectP(2);

      assert.isRejected(RA.allP([p1, p2, p3]), 1).notify(done);
    });
  });

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

    assert.eventually.deepEqual(allP([1, 2, 3]), [1, 2, 3]).notify(done);
  });
});
{'fraction_non_alphanumeric': 0.17538688282977155, 'fraction_numerical': 0.026529108327192335, 'mean_word_length': 3.3411513859275055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7096797', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1372, 'n_words': 326}