Improve test coverage.

This commit is contained in:
John-David Dalton
2015-07-19 01:38:43 -07:00
parent 40409df885
commit bbe122aba5
2 changed files with 51 additions and 25 deletions

View File

@@ -3,7 +3,8 @@ node_js:
- "0.12"
env:
global:
- PATTERN1="s|\s*else\s*\{\s*iteratee\(index\);\s*\}||"
- PATTERN1="s|\s*if\s*\(isHostObject\b[\s\S]+?\}(?=\n)||"
- PATTERN2="s|\s*else\s*\{\s*iteratee\(index\);\s*\}||"
- BIN="node" ISTANBUL=false OPTION=""
- NPM_VERSION="^2.0.0" SAUCE_LABS=false SAUCE_USERNAME="lodash"
- secure: "tg1JFsIFnxzLaTboFPOnm+aJCuMm5+JdhLlESlqg9x3fwro++7KCnwHKLNovhchaPe4otC43ZMB/nfWhDnDm11dKbm/V6HlTkED+dadTsaLxVDg6J+7yK41QhokBPJOxLV78iDaNaAQVYEirAgZ0yn8kFubxmNKV+bpCGQNc9yU="
@@ -47,8 +48,8 @@ before_install:
# - "[ $BIN != 'ringo' ] || (sudo ln -s /opt/ringojs-0.11/bin/ringo /usr/local/bin/ringo && sudo chmod +x $_)"
- "git clone --depth=10 --branch=master git://github.com/lodash/lodash-cli ./node_modules/lodash-cli && mkdir $_/node_modules && cd $_ && ln -s ../../../ ./lodash && cd ../ && npm i && cd ../../"
- "node ./node_modules/lodash-cli/bin/lodash -o ./lodash.js"
- "[ $ISTANBUL == false ] || (perl -0pi -e \"$PATTERN1\" ./lodash.js && perl -0pi -e \"$PATTERN2\" ./lodash.js)"
script:
- "[ $ISTANBUL == false ] || perl -0pi -e \"$PATTERN\" ./lodash.js"
- "[ $ISTANBUL == false ] || node ./node_modules/istanbul/lib/cli.js cover -x \"**/vendor/**\" --report lcovonly ./test/test.js -- ./lodash.js"
- "[ $ISTANBUL == false ] || [ $TRAVIS_SECURE_ENV_VARS == false ] || (cat ./coverage/lcov.info | coveralls) || true"
- "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || cd ./test"

View File

@@ -1027,14 +1027,6 @@
var args = arguments,
array = ['a', 'b', 'c'];
_.each(empties, function(value) {
if (value !== 0) {
array[value] = 1;
}
});
array['1.1'] = array['-1'] = 1;
test('should return the elements corresponding to the specified keys', 1, function() {
var actual = _.at(array, [0, 2]);
deepEqual(actual, ['a', 'c']);
@@ -1045,11 +1037,15 @@
deepEqual(actual, ['c', undefined, 'a']);
});
test('should work with non-index keys on array-like values', 1, function() {
test('should work with non-index keys on array values', 1, function() {
var values = _.reject(empties, function(value) {
return value === 0 || _.isArray(value);
}).concat(-1, 1.1);
var array = _.transform(values, function(result, value) {
result[value] = 1;
}, []);
var expected = _.map(values, _.constant(1)),
actual = _.at(array, values);
@@ -7941,11 +7937,16 @@
strictEqual(_.isPlainObject(new Foo(1)), false);
});
test('should return `true` for objects with a `[[Prototype]]` of `null`', 1, function() {
test('should return `true` for objects with a `[[Prototype]]` of `null`', 2, function() {
if (create) {
strictEqual(_.isPlainObject(create(null)), true);
} else {
skipTest();
var object = create(null);
strictEqual(_.isPlainObject(object), true);
object.constructor = objectProto.constructor;
strictEqual(_.isPlainObject(object), true);
}
else {
skipTest(2);
}
});
@@ -12342,6 +12343,16 @@
deepEqual(actual, ['c', undefined, 'a']);
});
test('should flatten `indexes`', 4, function() {
var array = ['a', 'b', 'c'];
deepEqual(_.pullAt(array, 2, 0), ['c', 'a']);
deepEqual(array, ['b']);
array = ['a', 'b', 'c', 'd'];
deepEqual(_.pullAt(array, [3, 0], 2), ['d', 'a', 'c']);
deepEqual(array, ['b']);
});
test('should return an empty array when no indexes are provided', 4, function() {
var array = ['a', 'b', 'c'],
actual = _.pullAt(array);
@@ -12355,20 +12366,34 @@
deepEqual(actual, []);
});
test('should accept multiple index arguments', 2, function() {
var array = ['a', 'b', 'c', 'd'],
actual = _.pullAt(array, 3, 0, 2);
test('should work with non-index paths', 2, function() {
var values = _.reject(empties, function(value) {
return value === 0 || _.isArray(value);
}).concat(-1, 1.1);
deepEqual(array, ['b']);
deepEqual(actual, ['d', 'a', 'c']);
var array = _.transform(values, function(result, value) {
result[value] = 1;
}, []);
var expected = _.map(values, _.constant(1)),
actual = _.pullAt(array, values);
deepEqual(actual, expected);
expected = _.map(values, _.constant(undefined)),
actual = _.at(array, values);
deepEqual(actual, expected);
});
test('should accept multiple arrays of indexes', 2, function() {
var array = ['a', 'b', 'c', 'd'],
actual = _.pullAt(array, [3], [0, 2]);
test('should work with deep paths', 2, function() {
var array = [];
array.a = { 'b': { 'c': 3 } };
deepEqual(array, ['b']);
deepEqual(actual, ['d', 'a', 'c']);
var actual = _.pullAt(array, 'a.b.c');
deepEqual(actual, [3]);
deepEqual(array.a, { 'b': {} });
});
test('should work with a falsey `array` argument when keys are provided', 1, function() {