Blame test.js

Jared K. Smith ff83892
/*!
Jared K. Smith ff83892
 * arr-union <https://github.com/jonschlinkert/arr-union>
Jared K. Smith ff83892
 *
Jared K. Smith ff83892
 * Copyright (c) 2014-2015, Jon Schlinkert.
Jared K. Smith ff83892
 * Licensed under the MIT License.
Jared K. Smith ff83892
 */
Jared K. Smith ff83892
Jared K. Smith ff83892
'use strict';
Jared K. Smith ff83892
Jared K. Smith ff83892
/* deps:mocha */
Jared K. Smith ff83892
var path = require('path');
Jared K. Smith ff83892
var argv = require('minimist')(process.argv.slice(2));
Jared K. Smith ff83892
var should = require('should');
Jared K. Smith ff83892
var union = require('./');
Jared K. Smith ff83892
Jared K. Smith ff83892
if (argv._.length) {
Jared K. Smith ff83892
  union = require(path.resolve('benchmark/code/' + argv.code + '.js'));
Jared K. Smith ff83892
}
Jared K. Smith ff83892
Jared K. Smith ff83892
describe('union', function() {
Jared K. Smith ff83892
  it('should add elements to the original array:', function() {
Jared K. Smith ff83892
    var arr = ['a'];
Jared K. Smith ff83892
    union(arr, ['b', 'c'], ['a'], ['b', 'c'], ['d', 'e', 'f']).sort()
Jared K. Smith ff83892
    arr.should.eql(['a', 'b', 'c', 'd', 'e', 'f'].sort());
Jared K. Smith ff83892
  });
Jared K. Smith ff83892
Jared K. Smith ff83892
  it('should union all elements in the given arrays:', function() {
Jared K. Smith ff83892
    union(['a'], ['b', 'c'], ['d', 'e', 'f']).sort().should.eql(['a', 'b', 'c', 'd', 'e', 'f'].sort());
Jared K. Smith ff83892
  });
Jared K. Smith ff83892
Jared K. Smith ff83892
  it('should ignore falsey values', function() {
Jared K. Smith ff83892
    union(['a'], undefined, ['d', 'e', 'f']).sort().should.eql(['a', 'd', 'e', 'f'].sort());
Jared K. Smith ff83892
  });
Jared K. Smith ff83892
Jared K. Smith ff83892
  it('should arrayify non-array values', function() {
Jared K. Smith ff83892
    union(['a'], 'cde', ['d', 'e', 'f']).sort().should.eql(['a', 'cde', 'd', 'e', 'f'].sort());
Jared K. Smith ff83892
  });
Jared K. Smith ff83892
Jared K. Smith ff83892
  it('should uniquify elements from additional arrays:', function() {
Jared K. Smith ff83892
    var arr = ['a', 'b', 'c'];
Jared K. Smith ff83892
    var res = union(arr, ['b', 'c'], ['a'], ['b', 'c'], ['d', 'e', 'f']).sort()
Jared K. Smith ff83892
    res.should.eql(['a', 'b', 'c', 'd', 'e', 'f'].sort());
Jared K. Smith ff83892
  });
Jared K. Smith ff83892
});
Jared K. Smith ff83892