2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

Moving utility functions into utils

This commit is contained in:
Matt Zabriskie
2014-08-28 12:33:53 -06:00
parent ceca9ced47
commit cec3482ff7
17 changed files with 971 additions and 647 deletions
+55
View File
@@ -0,0 +1,55 @@
var forEach = require('../../../lib/utils').forEach;
module.exports = {
testArray: function (test) {
var sum = 0;
forEach([1, 2, 3, 4, 5], function (val) {
sum += val;
});
test.equal(sum, 15);
test.done();
},
testObject: function (test) {
var keys = '';
var vals = 0;
var obj = {
b: 1,
a: 2,
r: 3
};
forEach(obj, function (v, k) {
keys += k;
vals += v;
});
test.equal(keys, 'bar');
test.equal(vals, 6);
test.done();
},
testUndefined: function (test) {
var count = 0;
forEach(undefined, function () {
count++;
});
test.equals(count, 0);
test.done();
},
testFunction: function (test) {
var count = 0;
forEach(function () {}, function () {
count++;
})
test.equals(count, 1);
test.done();
}
};