mirror of
https://github.com/tenrok/axios.git
synced 2026-05-15 11:59:42 +03:00
Adding baseURL to be used in getUri(), also removing question mark trimming since there seems to be no obvious reason for it. (#3737)
Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -42,6 +42,10 @@ describe('static api', function () {
|
||||
expect(typeof axios.isCancel).toEqual('function');
|
||||
});
|
||||
|
||||
it('should have getUri method', function() {
|
||||
expect(typeof axios.getUri).toEqual('function');
|
||||
});
|
||||
|
||||
it('should have isAxiosError properties', function () {
|
||||
expect(typeof axios.isAxiosError).toEqual('function');
|
||||
});
|
||||
|
||||
@@ -19,6 +19,7 @@ describe('instance', function () {
|
||||
'isCancel',
|
||||
'all',
|
||||
'spread',
|
||||
'getUri',
|
||||
'isAxiosError',
|
||||
'VERSION',
|
||||
'default'].indexOf(prop) > -1) {
|
||||
@@ -112,4 +113,40 @@ describe('instance', function () {
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
|
||||
it('should have getUri on the instance', function() {
|
||||
var instance = axios.create({
|
||||
baseURL: 'https://api.example.com'
|
||||
});
|
||||
var options = {
|
||||
url: 'foo/bar',
|
||||
params: {
|
||||
name: 'axios'
|
||||
}
|
||||
};
|
||||
expect(instance.getUri(options)).toBe('https://api.example.com/foo/bar?name=axios');
|
||||
});
|
||||
|
||||
it('should correctly build url without baseURL', function () {
|
||||
var instance = axios.create();
|
||||
var options = {
|
||||
url: 'foo/bar?foo=bar',
|
||||
params: {
|
||||
name: 'axios'
|
||||
}
|
||||
};
|
||||
expect(instance.getUri(options)).toBe('foo/bar?foo=bar&name=axios');
|
||||
});
|
||||
|
||||
it('should correctly discard url hash mark', function () {
|
||||
var instance = axios.create();
|
||||
var options = {
|
||||
baseURL: 'https://api.example.com',
|
||||
url: 'foo/bar?foo=bar#hash',
|
||||
params: {
|
||||
name: 'axios'
|
||||
}
|
||||
};
|
||||
expect(instance.getUri(options)).toBe('https://api.example.com/foo/bar?foo=bar&name=axios');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user