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

Moving many nodeunit tests to jasmine

This commit is contained in:
mzabriskie
2015-03-18 17:12:51 -06:00
parent b745600ab7
commit fc12b933f7
19 changed files with 264 additions and 260 deletions
-68
View File
@@ -1,68 +0,0 @@
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();
},
testArguments: function (test) {
var sum = 0;
(function () {
forEach(arguments, function (val) {
sum += val;
});
})(1, 2, 3, 4, 5);
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();
}
};
-60
View File
@@ -1,60 +0,0 @@
var utils = require('../../../lib/utils');
module.exports = {
testIsArray: function (test) {
test.equals(utils.isArray([]), true);
test.equals(utils.isArray({length: 5}), false);
test.done();
},
testIsArrayBuffer: function (test) {
test.equals(utils.isArrayBuffer(new ArrayBuffer(2)), true);
test.done();
},
testIsArrayBufferView: function (test) {
test.equals(utils.isArrayBufferView(new DataView(new ArrayBuffer(2))), true);
test.done();
},
// TODO These tests need a browser to run
// testIsFormData: function (test) {
// test.equals(utils.isFormData(new FormData()), true);
// test.done();
// },
//
// testIsBlob: function (test) {
// test.equals(utils.isBlob(new Blob(['<h1>Foo</h1>'], {type: 'text/html'})), true);
// test.done();
// },
testIsString: function (test) {
test.equals(utils.isString(''), true);
test.equals(utils.isString({toString: function () { return ''; }}), false);
test.done();
},
testIsNumber: function (test) {
test.equals(utils.isNumber(123), true);
test.equals(utils.isNumber('123'), false);
test.done();
},
testIsUndefined: function (test) {
test.equals(utils.isUndefined(), true);
test.equals(utils.isUndefined(null), false);
test.done();
},
testIsObject: function (test) {
test.equals(utils.isObject({}), true);
test.equals(utils.isObject(null), false);
test.done();
},
testIsDate: function (test) {
test.equals(utils.isDate(new Date()), true);
test.equals(utils.isDate(Date.now()), false);
test.done();
}
};
-28
View File
@@ -1,28 +0,0 @@
var merge = require('../../../lib/utils').merge;
module.exports = {
testImmutability: function (test) {
var a = {};
var b = {foo: 123};
var c = {bar: 456};
merge(a, b, c);
test.equals(typeof a.foo, 'undefined');
test.equals(typeof a.bar, 'undefined');
test.equals(typeof b.bar, 'undefined');
test.equals(typeof c.foo, 'undefined');
test.done();
},
testMerge: function (test) {
var a = {foo: 123};
var b = {bar: 456};
var c = {foo: 789};
var d = merge(a, b, c);
test.equals(d.foo, 789);
test.equals(d.bar, 456);
test.done();
}
};
-13
View File
@@ -1,13 +0,0 @@
var trim = require('../../../lib/utils').trim;
module.exports = {
testTrim: function (test) {
test.equals(trim(' foo '), 'foo');
test.done();
},
testTrimTab: function (test) {
test.equals(trim('\tfoo'), 'foo');
test.done();
}
};