|
Jared K. Smith |
14e81a0 |
/*!
|
|
Jared K. Smith |
14e81a0 |
* array-unique <https://github.com/jonschlinkert/array-unique>
|
|
Jared K. Smith |
14e81a0 |
*
|
|
Jared K. Smith |
14e81a0 |
* Copyright (c) 2014-2015, Jon Schlinkert.
|
|
Jared K. Smith |
14e81a0 |
* Licensed under the MIT License.
|
|
Jared K. Smith |
14e81a0 |
*/
|
|
Jared K. Smith |
14e81a0 |
|
|
Jared K. Smith |
14e81a0 |
'use strict';
|
|
Jared K. Smith |
14e81a0 |
|
|
Jared K. Smith |
937f8f1 |
require('mocha');
|
|
Jared K. Smith |
14e81a0 |
var assert = require('assert');
|
|
Jared K. Smith |
14e81a0 |
var should = require('should');
|
|
Jared K. Smith |
14e81a0 |
var unique = require('./');
|
|
Jared K. Smith |
14e81a0 |
|
|
Jared K. Smith |
937f8f1 |
describe('unique', function() {
|
|
Jared K. Smith |
937f8f1 |
it('should throw an error if the value passed is not an array:', function() {
|
|
Jared K. Smith |
937f8f1 |
(function() {
|
|
Jared K. Smith |
14e81a0 |
unique('a', 'b', 'c');
|
|
Jared K. Smith |
14e81a0 |
}).should.throw('array-unique expects an array.');
|
|
Jared K. Smith |
14e81a0 |
});
|
|
Jared K. Smith |
14e81a0 |
|
|
Jared K. Smith |
937f8f1 |
it('should return an array with unique values:', function() {
|
|
Jared K. Smith |
14e81a0 |
unique(['a', 'b', 'c', 'a', 'b', 'd']).should.eql(['a', 'b', 'c', 'd']);
|
|
Jared K. Smith |
14e81a0 |
unique(['a', 'b', 'c', 'a', 'b', 'a', 'b', 'c', 'b', 'f', 'a', 'b']).should.eql(['a', 'b', 'c', 'f']);
|
|
Jared K. Smith |
14e81a0 |
unique(['a', 'b', 'c', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b']).should.eql(['a', 'b', 'c', 'f', 'x', 'y', 'z']);
|
|
Jared K. Smith |
14e81a0 |
unique(['foo/bar/baz/quux/fez/test/fixtures', 'foo/bar/baz/quux/fez/test/fixtures', 'foo/bar/baz/quux/fez/test/fixtures/a.js', 'foo/bar/baz/quux/fez/test/fixtures', 'foo/bar/baz/quux/fez/test/fixtures', 'foo/bar/baz/quux/fez/test/fixtures/b.js', 'foo/bar/baz/quux/fez/test/fixtures/b.js', 'foo/bar/baz/quux/fez/test/fixtures', 'foo/bar/baz/quux/fez/test/fixtures', 'foo/bar/baz/quux/fez/test/fixtures/a.js', 'foo/bar/baz/quux/fez/test/fixtures/j.js', 'foo/bar/baz/quux/fez/test/fixtures/z.js', 'foo/bar/baz/quux/fez/test/fixtures/c.js', 'foo/bar/baz/quux/fez/test/fixtures/d.js', 'foo/bar/baz/quux/fez/test/fixtures', 'foo/bar/baz/quux/fez/test/fixtures/a.js', 'foo/bar/baz/quux/fez/test/fixtures', 'foo/bar/baz/quux/fez/test/fixtures/h.js', 'foo/bar/baz/quux/fez/test/fixtures/i.js', 'foo/bar/baz/quux/fez/test/fixtures/j.js', 'foo/bar/baz/quux/fez/test/fixtures/k.js', 'foo/bar/baz/quux/fez/test/fixtures/l.js', 'foo/bar/baz/quux/fez/test/fixtures/m.js', 'foo/bar/baz/quux/fez/test/fixtures', 'foo/bar/baz/quux/fez/test/fixtures/a.js']).should.eql([
|
|
Jared K. Smith |
14e81a0 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
14e81a0 |
'foo/bar/baz/quux/fez/test/fixtures/a.js',
|
|
Jared K. Smith |
14e81a0 |
'foo/bar/baz/quux/fez/test/fixtures/b.js',
|
|
Jared K. Smith |
14e81a0 |
'foo/bar/baz/quux/fez/test/fixtures/j.js',
|
|
Jared K. Smith |
14e81a0 |
'foo/bar/baz/quux/fez/test/fixtures/z.js',
|
|
Jared K. Smith |
14e81a0 |
'foo/bar/baz/quux/fez/test/fixtures/c.js',
|
|
Jared K. Smith |
14e81a0 |
'foo/bar/baz/quux/fez/test/fixtures/d.js',
|
|
Jared K. Smith |
14e81a0 |
'foo/bar/baz/quux/fez/test/fixtures/h.js',
|
|
Jared K. Smith |
14e81a0 |
'foo/bar/baz/quux/fez/test/fixtures/i.js',
|
|
Jared K. Smith |
14e81a0 |
'foo/bar/baz/quux/fez/test/fixtures/k.js',
|
|
Jared K. Smith |
14e81a0 |
'foo/bar/baz/quux/fez/test/fixtures/l.js',
|
|
Jared K. Smith |
14e81a0 |
'foo/bar/baz/quux/fez/test/fixtures/m.js'
|
|
Jared K. Smith |
14e81a0 |
]);
|
|
Jared K. Smith |
14e81a0 |
});
|
|
Jared K. Smith |
14e81a0 |
});
|
|
Jared K. Smith |
14e81a0 |
|
|
Jared K. Smith |
937f8f1 |
describe('unique.immutable', function() {
|
|
Jared K. Smith |
937f8f1 |
it('should throw an error if the value passed is not an array:', function() {
|
|
Jared K. Smith |
937f8f1 |
(function() {
|
|
Jared K. Smith |
937f8f1 |
unique.immutable('a', 'b', 'c');
|
|
Jared K. Smith |
937f8f1 |
}).should.throw('array-unique expects an array.');
|
|
Jared K. Smith |
937f8f1 |
});
|
|
Jared K. Smith |
937f8f1 |
|
|
Jared K. Smith |
937f8f1 |
it('should return an array with unique values without modifying the input:', function() {
|
|
Jared K. Smith |
937f8f1 |
(function() {
|
|
Jared K. Smith |
937f8f1 |
var original = ['a', 'b', 'c', 'a', 'b', 'd'];
|
|
Jared K. Smith |
937f8f1 |
var before = ['a', 'b', 'c', 'a', 'b', 'd'];
|
|
Jared K. Smith |
937f8f1 |
var expected = ['a', 'b', 'c', 'd'];
|
|
Jared K. Smith |
937f8f1 |
|
|
Jared K. Smith |
937f8f1 |
unique.immutable(before).should.eql(expected);
|
|
Jared K. Smith |
937f8f1 |
before.should.eql(original);
|
|
Jared K. Smith |
937f8f1 |
})();
|
|
Jared K. Smith |
937f8f1 |
|
|
Jared K. Smith |
937f8f1 |
(function() {
|
|
Jared K. Smith |
937f8f1 |
var original = ['a', 'b', 'c', 'a', 'b', 'a', 'b', 'c', 'b', 'f', 'a', 'b'];
|
|
Jared K. Smith |
937f8f1 |
var before = ['a', 'b', 'c', 'a', 'b', 'a', 'b', 'c', 'b', 'f', 'a', 'b'];
|
|
Jared K. Smith |
937f8f1 |
var expected = ['a', 'b', 'c', 'f'];
|
|
Jared K. Smith |
937f8f1 |
|
|
Jared K. Smith |
937f8f1 |
unique.immutable(before).should.eql(expected);
|
|
Jared K. Smith |
937f8f1 |
before.should.eql(original);
|
|
Jared K. Smith |
937f8f1 |
})();
|
|
Jared K. Smith |
937f8f1 |
|
|
Jared K. Smith |
937f8f1 |
(function() {
|
|
Jared K. Smith |
937f8f1 |
var original = ['a', 'b', 'c', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b']
|
|
Jared K. Smith |
937f8f1 |
var before = ['a', 'b', 'c', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b', 'a', 'b', 'a', 'b', 'b', 'f', 'a', 'b', 'x', 'y', 'z', 'a', 'b']
|
|
Jared K. Smith |
937f8f1 |
var expected = ['a', 'b', 'c', 'f', 'x', 'y', 'z'];
|
|
Jared K. Smith |
937f8f1 |
unique.immutable(before).should.eql(expected);
|
|
Jared K. Smith |
937f8f1 |
before.should.eql(original);
|
|
Jared K. Smith |
937f8f1 |
})();
|
|
Jared K. Smith |
937f8f1 |
|
|
Jared K. Smith |
937f8f1 |
(function() {
|
|
Jared K. Smith |
937f8f1 |
var original = [
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/a.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/b.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/b.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/a.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/j.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/z.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/c.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/d.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/a.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/h.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/i.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/j.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/k.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/l.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/m.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/a.js'
|
|
Jared K. Smith |
937f8f1 |
];
|
|
Jared K. Smith |
937f8f1 |
var before = [
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/a.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/b.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/b.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/a.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/j.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/z.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/c.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/d.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/a.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/h.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/i.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/j.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/k.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/l.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/m.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/a.js'
|
|
Jared K. Smith |
937f8f1 |
];
|
|
Jared K. Smith |
937f8f1 |
var expected = [
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/a.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/b.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/j.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/z.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/c.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/d.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/h.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/i.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/k.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/l.js',
|
|
Jared K. Smith |
937f8f1 |
'foo/bar/baz/quux/fez/test/fixtures/m.js'
|
|
Jared K. Smith |
937f8f1 |
];
|
|
Jared K. Smith |
937f8f1 |
|
|
Jared K. Smith |
937f8f1 |
unique.immutable(before).should.eql(expected);
|
|
Jared K. Smith |
937f8f1 |
before.should.eql(original);
|
|
Jared K. Smith |
937f8f1 |
})();
|
|
Jared K. Smith |
937f8f1 |
});
|
|
Jared K. Smith |
937f8f1 |
});
|