mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
Changing btoa ponyfill to improve testing
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
var axios = require('../../index');
|
||||
var validateInvalidCharacterError = require('./__validateInvalidCharacterError');
|
||||
|
||||
module.exports = function setupBasicAuthTest() {
|
||||
beforeEach(function () {
|
||||
@@ -36,7 +37,7 @@ module.exports = function setupBasicAuthTest() {
|
||||
}).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');
|
||||
validateInvalidCharacterError(error);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
module.exports = function validateInvalidCharacterError(error) {
|
||||
expect(error instanceof Error).toEqual(true);
|
||||
expect(/character/i.test(error.message)).toEqual(true);
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
var __btoa = require('../../../lib/helpers/btoa');
|
||||
var validateInvalidCharacterError = require('../__validateInvalidCharacterError');
|
||||
|
||||
describe('btoa polyfill', function () {
|
||||
it('should behave the same as native window.btoa', function () {
|
||||
@@ -22,6 +23,7 @@ describe('btoa polyfill', function () {
|
||||
err2 = e;
|
||||
}
|
||||
|
||||
expect(err1.message).toEqual(err2.message);
|
||||
validateInvalidCharacterError(err1);
|
||||
validateInvalidCharacterError(err2);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user