-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtest.js
151 lines (139 loc) · 8.9 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*!
* array-unique <https://github.com/jonschlinkert/array-unique>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
require('mocha');
var assert = require('assert');
var should = require('should');
var unique = require('./');
describe('unique', function() {
it('should throw an error if the value passed is not an array:', function() {
(function() {
unique('a', 'b', 'c');
}).should.throw('array-unique expects an array.');
});
it('should return an array with unique values:', function() {
unique(['a', 'b', 'c', 'a', 'b', 'd']).should.eql(['a', 'b', 'c', 'd']);
unique(['a', 'b', 'c', 'a', 'b', 'a', 'b', 'c', 'b', 'f', 'a', 'b']).should.eql(['a', 'b', 'c', 'f']);
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']);
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([
'foo/bar/baz/quux/fez/test/fixtures',
'foo/bar/baz/quux/fez/test/fixtures/a.js',
'foo/bar/baz/quux/fez/test/fixtures/b.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/h.js',
'foo/bar/baz/quux/fez/test/fixtures/i.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'
]);
});
});
describe('unique.immutable', function() {
it('should throw an error if the value passed is not an array:', function() {
(function() {
unique.immutable('a', 'b', 'c');
}).should.throw('array-unique expects an array.');
});
it('should return an array with unique values without modifying the input:', function() {
(function() {
var original = ['a', 'b', 'c', 'a', 'b', 'd'];
var before = ['a', 'b', 'c', 'a', 'b', 'd'];
var expected = ['a', 'b', 'c', 'd'];
unique.immutable(before).should.eql(expected);
before.should.eql(original);
})();
(function() {
var original = ['a', 'b', 'c', 'a', 'b', 'a', 'b', 'c', 'b', 'f', 'a', 'b'];
var before = ['a', 'b', 'c', 'a', 'b', 'a', 'b', 'c', 'b', 'f', 'a', 'b'];
var expected = ['a', 'b', 'c', 'f'];
unique.immutable(before).should.eql(expected);
before.should.eql(original);
})();
(function() {
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']
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']
var expected = ['a', 'b', 'c', 'f', 'x', 'y', 'z'];
unique.immutable(before).should.eql(expected);
before.should.eql(original);
})();
(function() {
var original = [
'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'
];
var before = [
'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'
];
var expected = [
'foo/bar/baz/quux/fez/test/fixtures',
'foo/bar/baz/quux/fez/test/fixtures/a.js',
'foo/bar/baz/quux/fez/test/fixtures/b.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/h.js',
'foo/bar/baz/quux/fez/test/fixtures/i.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'
];
unique.immutable(before).should.eql(expected);
before.should.eql(original);
})();
});
});