Skip to content

Commit 2c27a46

Browse files
authored
Merge pull request #226 from jgonggrijp/update-test
2 parents cea7332 + 474cbd5 commit 2c27a46

27 files changed

+3103
-14992
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,29 @@ Create your own fork of contrib where you can make your changes.
1010

1111
## 3. Install development dependencies
1212

13-
Make sure you have [Node.js][node] and the [grunt cli][cli] installed. Then install contrib's development dependencies with `npm install`.
13+
Make sure you have [Node.js][node] and [Yarn][yarn] installed. Then install contrib's development dependencies with `yarn`. Note that these dependencies include the [Grunt CLI][cli] which we use for task automation.
1414

1515
## 4. Change the code
1616

1717
Make your code changes, ensuring they adhere to the same [coding style as Underscore][style]. Do **not** edit the files in `dist/`.
1818

19-
Make any necessary updates to the qUnit tests found in `test/`. Run `grunt test` to catch any test failures or lint issues. You can also use `grunt watch:test` to get instant feedback each time you save a file.
19+
Make any necessary updates to the qUnit tests found in `test/`. Run `yarn test` to catch any test failures or lint issues. You can also use `yarn grunt watch:test` to get instant feedback each time you save a file.
2020

2121
## 5. Update the docs
2222

2323
Make any necessary documentation updates in `docs/`. Do **not** edit `index.html` directly.
2424

25-
After updating the docs, run `grunt tocdoc` to rebuild the `index.html` file. Visually inspect `index.html` in your browser to ensure the generated docs look nice.
25+
After updating the docs, run `yarn tocdoc` to rebuild the `index.html` file. Visually inspect `index.html` in your browser to ensure the generated docs look nice.
2626

2727
## 6. Send a pull request
2828

2929
Send a pull request to `documentcloud/underscore-contrib` for feedback.
3030

31-
If modifications are necessary, make the changes and rerun `grunt test` or `grunt tocdoc` as needed.
31+
If modifications are necessary, make the changes and rerun `yarn test` or `yarn tocdoc` as needed.
3232

3333
And hopefully your pull request will be merged by the core team! :-)
3434

3535
[style]:https://github.com/documentcloud/underscore/blob/master/underscore.js
3636
[node]:http://nodejs.org/
37-
[cli]:http://gruntjs.com/getting-started#installing-the-cli
37+
[yarn]:https://classic.yarnpkg.com/
38+
[cli]:http://gruntjs.com/getting-started#installing-the-cli

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
"version": "0.3.0",
44
"main": "index.js",
55
"dependencies": {
6-
"underscore": "1.7.0"
6+
"underscore": "1.10.2"
77
},
88
"devDependencies": {
9-
"grunt": "^1.2.0",
9+
"grunt": "^1.3.0",
1010
"grunt-cli": "^1.3.2",
11-
"grunt-contrib-concat": "0.3.0",
11+
"grunt-contrib-concat": "1.0.1",
1212
"grunt-contrib-jshint": "^2.1.0",
1313
"grunt-contrib-qunit": "^4.0.0",
14-
"grunt-contrib-uglify": "^4.0.1",
14+
"grunt-contrib-uglify": "^5.0.0",
1515
"grunt-contrib-watch": "^1.1.0",
16-
"grunt-docco": "~0.3.0",
16+
"grunt-docco": "~0.5.0",
1717
"grunt-tocdoc": "0.1.1",
18-
"qunit": "^2.10.0"
18+
"jquery": "3.5.1",
19+
"jslitmus": "^0.1.0",
20+
"qunit": "^2.11.0"
1921
},
2022
"repository": {
2123
"type": "git",

test/array.builders.js

Lines changed: 93 additions & 93 deletions
Large diffs are not rendered by default.

test/array.selectors.js

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,105 @@
11
$(document).ready(function() {
22

3-
module("underscore.array.selectors");
3+
QUnit.module("underscore.array.selectors");
44

5-
test("second", function() {
5+
QUnit.test("second", function(assert) {
66
var a = [1,2,3,4,5];
77

8-
equal(_.second(a), 2, 'should retrieve the 2nd element in an array');
9-
deepEqual(_.second(a, 5), [2,3,4,5], 'should retrieve all but the first element in an array');
10-
deepEqual(_.map([a,_.rest(a)], _.second), [2,3], 'should be usable in _.map');
8+
assert.equal(_.second(a), 2, 'should retrieve the 2nd element in an array');
9+
assert.deepEqual(_.second(a, 5), [2,3,4,5], 'should retrieve all but the first element in an array');
10+
assert.deepEqual(_.map([a,_.rest(a)], _.second), [2,3], 'should be usable in _.map');
1111
});
1212

13-
test("third", function() {
13+
QUnit.test("third", function(assert) {
1414
var a = [1,2,3,4,5];
1515

16-
equal(_.third(a), 3, 'should retrieve the 3rd element in an array');
17-
deepEqual(_.third(a, 5), [3,4,5], 'should retrieve all but the first and second element in an array');
18-
deepEqual(_.map([a,_.rest(a)], _.third), [3,4], 'should be usable in _.map');
16+
assert.equal(_.third(a), 3, 'should retrieve the 3rd element in an array');
17+
assert.deepEqual(_.third(a, 5), [3,4,5], 'should retrieve all but the first and second element in an array');
18+
assert.deepEqual(_.map([a,_.rest(a)], _.third), [3,4], 'should be usable in _.map');
1919
});
2020

21-
test("takeWhile", function() {
21+
QUnit.test("takeWhile", function(assert) {
2222
var isNeg = function(n) { return n < 0; };
2323

24-
deepEqual(_.takeWhile([-2,-1,0,1,2], isNeg), [-2,-1], 'should take elements until a function goes truthy');
25-
deepEqual(_.takeWhile([1,-2,-1,0,1,2], isNeg), [], 'should take elements until a function goes truthy');
24+
assert.deepEqual(_.takeWhile([-2,-1,0,1,2], isNeg), [-2,-1], 'should take elements until a function goes truthy');
25+
assert.deepEqual(_.takeWhile([1,-2,-1,0,1,2], isNeg), [], 'should take elements until a function goes truthy');
2626
});
2727

28-
test("dropWhile", function() {
28+
QUnit.test("dropWhile", function(assert) {
2929
var isNeg = function(n) { return n < 0; };
3030

31-
deepEqual(_.dropWhile([-2,-1,0,1,2], isNeg), [0,1,2], 'should drop elements until a function goes truthy');
32-
deepEqual(_.dropWhile([0,1,2], isNeg), [0,1,2], 'should drop elements until a function goes truthy');
33-
deepEqual(_.dropWhile([-2,-1], isNeg), [], 'should drop elements until a function goes truthy');
34-
deepEqual(_.dropWhile([1,-2,-1,0,1,2], isNeg), [1,-2,-1,0,1,2], 'should take elements until a function goes truthy');
35-
deepEqual(_.dropWhile([], isNeg), [], 'should handle empty arrays');
31+
assert.deepEqual(_.dropWhile([-2,-1,0,1,2], isNeg), [0,1,2], 'should drop elements until a function goes truthy');
32+
assert.deepEqual(_.dropWhile([0,1,2], isNeg), [0,1,2], 'should drop elements until a function goes truthy');
33+
assert.deepEqual(_.dropWhile([-2,-1], isNeg), [], 'should drop elements until a function goes truthy');
34+
assert.deepEqual(_.dropWhile([1,-2,-1,0,1,2], isNeg), [1,-2,-1,0,1,2], 'should take elements until a function goes truthy');
35+
assert.deepEqual(_.dropWhile([], isNeg), [], 'should handle empty arrays');
3636
});
3737

38-
test("splitWith", function() {
38+
QUnit.test("splitWith", function(assert) {
3939
var a = [1,2,3,4,5];
4040
var lessEq3p = function(n) { return n <= 3; };
4141
var lessEq3p$ = function(n) { return (n <= 3) ? true : null; };
4242

43-
deepEqual(_.splitWith(a, lessEq3p), [[1,2,3], [4,5]], 'should split an array when a function goes false');
44-
deepEqual(_.splitWith(a, lessEq3p$), [[1,2,3], [4,5]], 'should split an array when a function goes false');
45-
deepEqual(_.splitWith([], lessEq3p$), [[],[]], 'should split an empty array into two empty arrays');
43+
assert.deepEqual(_.splitWith(a, lessEq3p), [[1,2,3], [4,5]], 'should split an array when a function goes false');
44+
assert.deepEqual(_.splitWith(a, lessEq3p$), [[1,2,3], [4,5]], 'should split an array when a function goes false');
45+
assert.deepEqual(_.splitWith([], lessEq3p$), [[],[]], 'should split an empty array into two empty arrays');
4646
});
4747

48-
test("partitionBy", function() {
48+
QUnit.test("partitionBy", function(assert) {
4949
var a = [1, 2, null, false, undefined, 3, 4];
5050

51-
deepEqual(_.partitionBy(a, _.truthy), [[1,2], [null, false, undefined], [3,4]], 'should partition an array as a given predicate changes truth sense');
51+
assert.deepEqual(_.partitionBy(a, _.truthy), [[1,2], [null, false, undefined], [3,4]], 'should partition an array as a given predicate changes truth sense');
5252
});
5353

54-
test("best", function() {
54+
QUnit.test("best", function(assert) {
5555
var a = [1,2,3,4,5];
5656

57-
deepEqual(_.best(a, function(x,y) { return x > y; }), 5, 'should identify the best value based on criteria');
57+
assert.deepEqual(_.best(a, function(x,y) { return x > y; }), 5, 'should identify the best value based on criteria');
5858
});
5959

60-
test("keep", function() {
60+
QUnit.test("keep", function(assert) {
6161
var a = _.range(10);
6262
var eveny = function(e) { return (_.isEven(e)) ? e : undefined; };
6363

64-
deepEqual(_.keep(a, eveny), [0,2,4,6,8], 'should keep only even numbers in a range tagged with null fails');
65-
deepEqual(_.keep(a, _.isEven), [true, false, true, false, true, false, true, false, true, false], 'should keep all existy values corresponding to a predicate over a range');
64+
assert.deepEqual(_.keep(a, eveny), [0,2,4,6,8], 'should keep only even numbers in a range tagged with null fails');
65+
assert.deepEqual(_.keep(a, _.isEven), [true, false, true, false, true, false, true, false, true, false], 'should keep all existy values corresponding to a predicate over a range');
6666
});
6767

68-
test("nth", function() {
68+
QUnit.test("nth", function(assert) {
6969
var a = ['a','b','c'];
7070
var b = [['a'],['b'],[]];
7171

72-
equal(_.nth(a,0), 'a', 'should return the element at a given index into an array');
73-
equal(_.nth(a,100), undefined, 'should return undefined if out of bounds');
74-
deepEqual(_.map(b,function(e) { return _.nth(e,0); }), ['a','b',undefined], 'should be usable in _.map');
72+
assert.equal(_.nth(a,0), 'a', 'should return the element at a given index into an array');
73+
assert.equal(_.nth(a,100), undefined, 'should return undefined if out of bounds');
74+
assert.deepEqual(_.map(b,function(e) { return _.nth(e,0); }), ['a','b',undefined], 'should be usable in _.map');
7575
});
7676

77-
test("nths", function() {
77+
QUnit.test("nths", function(assert) {
7878
var a = ['a','b','c', 'd'];
7979

80-
deepEqual(_.nths(a,1), ['b'], 'should return the element at a given index into an array');
81-
deepEqual(_.nths(a,1,3), ['b', 'd'], 'should return the elements at given indices into an array');
82-
deepEqual(_.nths(a,1,5,3), ['b', undefined, 'd'], 'should return undefined if out of bounds');
80+
assert.deepEqual(_.nths(a,1), ['b'], 'should return the element at a given index into an array');
81+
assert.deepEqual(_.nths(a,1,3), ['b', 'd'], 'should return the elements at given indices into an array');
82+
assert.deepEqual(_.nths(a,1,5,3), ['b', undefined, 'd'], 'should return undefined if out of bounds');
8383

84-
deepEqual(_.nths(a,[1]), ['b'], 'should return the element at a given index into an array');
85-
deepEqual(_.nths(a,[1,3]), ['b', 'd'], 'should return the elements at given indices into an array');
86-
deepEqual(_.nths(a,[1,5,3]), ['b', undefined, 'd'], 'should return undefined if out of bounds');
84+
assert.deepEqual(_.nths(a,[1]), ['b'], 'should return the element at a given index into an array');
85+
assert.deepEqual(_.nths(a,[1,3]), ['b', 'd'], 'should return the elements at given indices into an array');
86+
assert.deepEqual(_.nths(a,[1,5,3]), ['b', undefined, 'd'], 'should return undefined if out of bounds');
8787
});
8888

89-
test("valuesAt", function() {
90-
equal(_.valuesAt, _.nths, 'valuesAt should be alias for nths');
89+
QUnit.test("valuesAt", function(assert) {
90+
assert.equal(_.valuesAt, _.nths, 'valuesAt should be alias for nths');
9191
});
9292

93-
test("binPick", function() {
93+
QUnit.test("binPick", function(assert) {
9494
var a = ['a','b','c', 'd'];
9595

96-
deepEqual(_.binPick(a, false, true), ['b'], 'should return the element at a given index into an array');
97-
deepEqual(_.binPick(a, false, true, false, true), ['b', 'd'], 'should return the elements at given indices into an array');
98-
deepEqual(_.binPick(a, false, true, false, true, true), ['b', 'd', undefined], 'should return undefined if out of bounds');
96+
assert.deepEqual(_.binPick(a, false, true), ['b'], 'should return the element at a given index into an array');
97+
assert.deepEqual(_.binPick(a, false, true, false, true), ['b', 'd'], 'should return the elements at given indices into an array');
98+
assert.deepEqual(_.binPick(a, false, true, false, true, true), ['b', 'd', undefined], 'should return undefined if out of bounds');
9999

100-
deepEqual(_.binPick(a, [false, true]), ['b'], 'should return the element at a given index into an array');
101-
deepEqual(_.binPick(a, [false, true, false, true]), ['b', 'd'], 'should return the elements at given indices into an array');
102-
deepEqual(_.binPick(a, [false, true, false, true, true]), ['b', 'd', undefined], 'should return undefined if out of bounds');
100+
assert.deepEqual(_.binPick(a, [false, true]), ['b'], 'should return the element at a given index into an array');
101+
assert.deepEqual(_.binPick(a, [false, true, false, true]), ['b', 'd'], 'should return the elements at given indices into an array');
102+
assert.deepEqual(_.binPick(a, [false, true, false, true, true]), ['b', 'd', undefined], 'should return undefined if out of bounds');
103103
});
104104
});
105105

0 commit comments

Comments
 (0)