<commit_before>/**
 * @venus-include ../source/static.js
 * @venus-include ../lib/bluebird.js
 * @venus-include ../test-helpers.js
 */

/*
 *  static.spec.js
 *  --------------
 *  Tests the functionality that takes the config and creates
 *  static functions on the created Stirrup instance.
 */

var Library = Promise.noConflict();
Stirrup.prototype.getConfig = sinon.stub().returns({
  constructor: null
});
Stirrup.prototype.buildStaticFunctions = sinon.stub();

describe('Stirrup Static Functions', function() {

  var instance;

  describe('all', function() {
    it('should resolve when and only when all promises have resolved', function(done) {
      instance = new Stirrup(Library);

      var fulfilled = sinon.spy();
      var rejected = sinon.spy();

      var promise1 = new instance.Promise(function(r) { r(); });
      var d = instance.defer();
      var promise2 = d.promise;

      instance.all([promise1, promise2]).then(function() {
        expect(rejected.called).to.be(false);
        done();
      }, rejected).then(null, done);

      expect(fulfilled.called).to.be(false);

      d.fulfill();
    });
  });
});<commit_msg>Get initial static tests working<commit_after>/**
 * @venus-include ../source/static.js
 * @venus-include ../lib/bluebird.js
 * @venus-include ../test-helpers.js
 */

/*
 *  static.spec.js
 *  --------------
 *  Tests the functionality that takes the config and creates
 *  static functions on the created Stirrup instance.
 */

var Library = Promise.noConflict();
var Promise = null;
var instance;

var stubNative = function() {
  Promise = Library;
  Promise.toString = sinon.stub().returns('[native code]');
};

var unStubNative = function() {
  Promise = null;
};

Stirrup.prototype.getConfig = sinon.stub().returns({
  constructor: null,
  staticFuncs: {
    myLibFunction: {
      nativeName: 'myNativeFunction',
      aliases: [
        'someAlias',
        'someOtherAlias'
      ]
    },
    empty: {},
  }
});

describe('constructor', function() {

  describe('when native promises not available', function() {

    //If our environment has native promises, we need to remove them
    if(typeof Promise === 'function' && Promise.toString().indexOf('[native code]') > -1) {
      unStubNative();
    }

    it('should proxy library function to aliases', function() {
      instance = new Stirrup(Library);

      var originalFunc = Promise.myNativeFunction;

      expect(instance.someAlias).to.be(originalFunc);
      expect(instance.someOtherAlias).to.be(originalFunc);
    });
  });
  describe('when native promises available', function() {

    //If our environment doesn't have native promises, we need to stub them
    if(!(typeof Promise === 'function' && Promise.toString().indexOf('[native code]') > -1)) {
      stubNative();
    }

    it('should proxy native function to aliases', function() {
      instance = new Stirrup(Library);

      var originalFunc = Library.myLibFunction;

      expect(instance.someAlias).to.be(originalFunc);
      expect(instance.someOtherAlias).to.be(originalFunc);
    });
  });
});
{'fraction_non_alphanumeric': 0.15514443362544628, 'fraction_numerical': 0.0019474196689386564, 'mean_word_length': 3.120320855614973, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '2055006', 'n_tokens_mistral': 918, 'n_tokens_neox': 891, 'n_words': 221}