mirror of
https://github.com/tenrok/axios.git
synced 2026-06-08 17:22:34 +03:00
Merge branch 'master' of github.com:mzabriskie/axios into xDomainRequestSupport
Conflicts: lib/adapters/xhr.js
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
var buildUrl = require('../../../lib/helpers/buildUrl');
|
||||
var buildURL = require('../../../lib/helpers/buildURL');
|
||||
|
||||
describe('helpers::buildUrl', function () {
|
||||
describe('helpers::buildURL', function () {
|
||||
it('should support null params', function () {
|
||||
expect(buildUrl('/foo')).toEqual('/foo');
|
||||
expect(buildURL('/foo')).toEqual('/foo');
|
||||
});
|
||||
|
||||
it('should support params', function () {
|
||||
expect(buildUrl('/foo', {
|
||||
expect(buildURL('/foo', {
|
||||
foo: 'bar'
|
||||
})).toEqual('/foo?foo=bar');
|
||||
});
|
||||
|
||||
it('should support object params', function () {
|
||||
expect(buildUrl('/foo', {
|
||||
expect(buildURL('/foo', {
|
||||
foo: {
|
||||
bar: 'baz'
|
||||
}
|
||||
@@ -22,31 +22,31 @@ describe('helpers::buildUrl', function () {
|
||||
it('should support date params', function () {
|
||||
var date = new Date();
|
||||
|
||||
expect(buildUrl('/foo', {
|
||||
expect(buildURL('/foo', {
|
||||
date: date
|
||||
})).toEqual('/foo?date=' + date.toISOString());
|
||||
});
|
||||
|
||||
it('should support array params', function () {
|
||||
expect(buildUrl('/foo', {
|
||||
expect(buildURL('/foo', {
|
||||
foo: ['bar', 'baz']
|
||||
})).toEqual('/foo?foo[]=bar&foo[]=baz');
|
||||
});
|
||||
|
||||
it('should support special char params', function () {
|
||||
expect(buildUrl('/foo', {
|
||||
expect(buildURL('/foo', {
|
||||
foo: '@:$, '
|
||||
})).toEqual('/foo?foo=@:$,+');
|
||||
});
|
||||
|
||||
it('should support existing params', function () {
|
||||
expect(buildUrl('/foo?foo=bar', {
|
||||
expect(buildURL('/foo?foo=bar', {
|
||||
bar: 'baz'
|
||||
})).toEqual('/foo?foo=bar&bar=baz');
|
||||
});
|
||||
|
||||
it('should support "length" parameter', function () {
|
||||
expect(buildUrl('/foo', {
|
||||
expect(buildURL('/foo', {
|
||||
query: 'bar',
|
||||
start: 0,
|
||||
length: 5
|
||||
@@ -57,7 +57,7 @@ describe('helpers::buildUrl', function () {
|
||||
serializer = sinon.stub();
|
||||
params = {foo: 'bar'};
|
||||
serializer.returns('foo=bar');
|
||||
expect(buildUrl('/foo', params, serializer)).toEqual('/foo?foo=bar');
|
||||
expect(buildURL('/foo', params, serializer)).toEqual('/foo?foo=bar');
|
||||
expect(serializer.calledOnce).toBe(true);
|
||||
expect(serializer.calledWith(params)).toBe(true);
|
||||
})
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
var isURLSameOrigin = require('../../../lib/helpers/isURLSameOrigin');
|
||||
|
||||
describe('helpers::isURLSameOrigin', function () {
|
||||
it('should detect same origin', function () {
|
||||
expect(isURLSameOrigin(window.location.href)).toEqual(true);
|
||||
});
|
||||
|
||||
it('should detect different origin', function () {
|
||||
expect(isURLSameOrigin('https://github.com/mzabriskie/axios')).toEqual(false);
|
||||
});
|
||||
});
|
||||
@@ -1,11 +0,0 @@
|
||||
var urlIsSameOrigin = require('../../../lib/helpers/urlIsSameOrigin');
|
||||
|
||||
describe('helpers::urlIsSameOrigin', function () {
|
||||
it('should detect same origin', function () {
|
||||
expect(urlIsSameOrigin(window.location.href)).toEqual(true);
|
||||
});
|
||||
|
||||
it('should detect different origin', function () {
|
||||
expect(urlIsSameOrigin('https://github.com/mzabriskie/axios')).toEqual(false);
|
||||
});
|
||||
});
|
||||
@@ -11,18 +11,6 @@ describe('utils::forEach', function () {
|
||||
expect(sum).toEqual(15);
|
||||
});
|
||||
|
||||
it('should loop over arguments', function () {
|
||||
var sum = 0;
|
||||
|
||||
(function () {
|
||||
forEach(arguments, function (val) {
|
||||
sum += val;
|
||||
});
|
||||
})(1, 2, 3, 4, 5);
|
||||
|
||||
expect(sum).toEqual(15);
|
||||
});
|
||||
|
||||
it('should loop over object keys', function () {
|
||||
var keys = '';
|
||||
var vals = 0;
|
||||
@@ -61,4 +49,3 @@ describe('utils::forEach', function () {
|
||||
expect(count).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
var axios = require('../../../index');
|
||||
var http = require('http');
|
||||
var zlib = require('zlib');
|
||||
var server;
|
||||
|
||||
module.exports = {
|
||||
@@ -27,6 +28,29 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
testTransparentGunzip: function (test) {
|
||||
var data = {
|
||||
firstName: 'Fred',
|
||||
lastName: 'Flintstone',
|
||||
emailAddr: 'fred@example.com'
|
||||
};
|
||||
|
||||
zlib.gzip(JSON.stringify(data), function(err, zipped) {
|
||||
|
||||
server = http.createServer(function (req, res) {
|
||||
res.setHeader('Content-Type', 'application/json;charset=utf-8');
|
||||
res.setHeader('Content-Encoding', 'gzip');
|
||||
res.end(zipped);
|
||||
}).listen(4444, function () {
|
||||
axios.get('http://localhost:4444/').then(function (res) {
|
||||
test.deepEqual(res.data, data);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
testUTF8: function (test) {
|
||||
var str = Array(100000).join('ж');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user