mirror of
https://github.com/tenrok/axios.git
synced 2026-05-15 11:59:42 +03:00
603e7c84a0
Includes testing of the polyfills.
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
var axios = require('../../index');
|
|
|
|
describe('basicAuth without btoa polyfill', function () {
|
|
beforeEach(function () {
|
|
jasmine.Ajax.install();
|
|
});
|
|
|
|
afterEach(function () {
|
|
jasmine.Ajax.uninstall();
|
|
});
|
|
|
|
it('should accept HTTP Basic auth with username/password', function (done) {
|
|
axios({
|
|
url: '/foo',
|
|
auth: {
|
|
username: 'Aladdin',
|
|
password: 'open sesame'
|
|
}
|
|
});
|
|
|
|
setTimeout(function () {
|
|
var request = jasmine.Ajax.requests.mostRecent();
|
|
|
|
expect(request.requestHeaders['Authorization']).toEqual('Basic: QWxhZGRpbjpvcGVuIHNlc2FtZQ==');
|
|
done();
|
|
}, 0);
|
|
});
|
|
|
|
it('should fail to encode HTTP Basic auth credentials with non-Latin1 characters', function (done) {
|
|
axios({
|
|
url: '/foo',
|
|
auth: {
|
|
username: 'Aladßç£☃din',
|
|
password: 'open sesame'
|
|
}
|
|
}).then(function(response) {
|
|
done(new Error('Should not succeed to make a HTTP Basic auth request with non-latin1 chars in credentials.'))
|
|
}).catch(function(error) {
|
|
expect(error.message).toEqual('INVALID_CHARACTER_ERR: DOM Exception 5')
|
|
done()
|
|
});
|
|
});
|
|
});
|