mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Moving many nodeunit tests to jasmine
This commit is contained in:
@@ -1,67 +0,0 @@
|
||||
var buildUrl = require('../../../lib/helpers/buildUrl');
|
||||
|
||||
module.exports = {
|
||||
testNullParams: function (test) {
|
||||
var url = buildUrl('/foo');
|
||||
|
||||
test.equals(url, '/foo');
|
||||
test.done();
|
||||
},
|
||||
|
||||
testParams: function (test) {
|
||||
var url = buildUrl('/foo', {
|
||||
foo: 'bar'
|
||||
});
|
||||
|
||||
test.equals(url, '/foo?foo=bar');
|
||||
test.done();
|
||||
},
|
||||
|
||||
testObjectParam: function (test) {
|
||||
var url = buildUrl('/foo', {
|
||||
foo: {
|
||||
bar: 'baz'
|
||||
}
|
||||
});
|
||||
|
||||
test.equals(url, '/foo?foo=' + encodeURI('{"bar":"baz"}'));
|
||||
test.done();
|
||||
},
|
||||
|
||||
testDateParam: function (test) {
|
||||
var date = new Date();
|
||||
var url = buildUrl('/foo', {
|
||||
date: date
|
||||
});
|
||||
|
||||
test.equals(url, '/foo?date=' + date.toISOString());
|
||||
test.done();
|
||||
},
|
||||
|
||||
testArrayParam: function (test) {
|
||||
var url = buildUrl('/foo', {
|
||||
foo: ['bar', 'baz']
|
||||
});
|
||||
|
||||
test.equals(url, '/foo?foo=bar&foo=baz');
|
||||
test.done();
|
||||
},
|
||||
|
||||
testSpecialChars: function (test) {
|
||||
var url = buildUrl('/foo', {
|
||||
foo: '@:$, '
|
||||
});
|
||||
|
||||
test.equals(url, '/foo?foo=@:$,+');
|
||||
test.done();
|
||||
},
|
||||
|
||||
testQuestionMark: function (test) {
|
||||
var url = buildUrl('/foo?foo=bar', {
|
||||
bar: 'baz'
|
||||
});
|
||||
|
||||
test.equals(url, '/foo?foo=bar&bar=baz');
|
||||
test.done();
|
||||
}
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
var defaults = require('../../../lib/defaults');
|
||||
|
||||
module.exports = {
|
||||
testTransformRequestJson: function (test) {
|
||||
var data = defaults.transformRequest[0]({foo: 'bar'});
|
||||
|
||||
test.equals(data, '{"foo":"bar"}');
|
||||
test.done();
|
||||
},
|
||||
|
||||
testTransformRequestString: function (test) {
|
||||
var data = defaults.transformRequest[0]('foo=bar');
|
||||
|
||||
test.equals(data, 'foo=bar');
|
||||
test.done();
|
||||
},
|
||||
|
||||
testTransformResponseJson: function (test) {
|
||||
var data = defaults.transformResponse[0]('{"foo":"bar"}');
|
||||
|
||||
test.equals(typeof data, 'object');
|
||||
test.equals(data.foo, 'bar');
|
||||
test.done();
|
||||
},
|
||||
|
||||
testTransformResponseString: function (test) {
|
||||
var data = defaults.transformResponse[0]('foo=bar');
|
||||
|
||||
test.equals(data, 'foo=bar');
|
||||
test.done();
|
||||
}
|
||||
};
|
||||
@@ -1,19 +0,0 @@
|
||||
var parseHeaders = require('../../../lib/helpers/parseHeaders');
|
||||
|
||||
module.exports = {
|
||||
testParse: function (test) {
|
||||
var date = new Date();
|
||||
var parsed = parseHeaders(
|
||||
'Date: ' + date.toISOString() + '\n' +
|
||||
'Content-Type: application/json\n' +
|
||||
'Connection: keep-alive\n' +
|
||||
'Transfer-Encoding: chunked'
|
||||
);
|
||||
|
||||
test.equals(parsed['date'], date.toISOString());
|
||||
test.equals(parsed['content-type'], 'application/json');
|
||||
test.equals(parsed['connection'], 'keep-alive');
|
||||
test.equals(parsed['transfer-encoding'], 'chunked');
|
||||
test.done();
|
||||
}
|
||||
};
|
||||
@@ -1,13 +0,0 @@
|
||||
var spread = require('../../../lib/helpers/spread');
|
||||
|
||||
module.exports = {
|
||||
testSpread: function (test) {
|
||||
var value = 0;
|
||||
spread(function (a, b) {
|
||||
value = a * b;
|
||||
})([5, 10]);
|
||||
|
||||
test.equals(value, 50);
|
||||
test.done();
|
||||
}
|
||||
};
|
||||
@@ -1,31 +0,0 @@
|
||||
var transformData = require('../../../lib/helpers/transformData');
|
||||
|
||||
module.exports = {
|
||||
testSingleFunction: function (test) {
|
||||
var data;
|
||||
data = transformData(data, null, function (data) {
|
||||
data = 'foo';
|
||||
return data;
|
||||
});
|
||||
|
||||
test.equals(data, 'foo');
|
||||
test.done();
|
||||
},
|
||||
|
||||
testFunctionArray: function (test) {
|
||||
var data = '';
|
||||
data = transformData(data, null, [function (data) {
|
||||
data += 'f';
|
||||
return data;
|
||||
}, function (data) {
|
||||
data += 'o';
|
||||
return data;
|
||||
}, function (data) {
|
||||
data += 'o';
|
||||
return data;
|
||||
}]);
|
||||
|
||||
test.equals(data, 'foo');
|
||||
test.done();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user