2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-08 17:22:34 +03:00
Files
axios/test/specs/helpers/btoa.spec.js
T
2016-03-03 22:43:16 -07:00

30 lines
703 B
JavaScript

var __btoa = require('../../../lib/helpers/btoa');
var validateInvalidCharacterError = require('../__validateInvalidCharacterError');
describe('btoa polyfill', function () {
it('should behave the same as native window.btoa', function () {
var data = 'Hello, world';
expect(__btoa(data)).toEqual(window.btoa(data));
});
it('should throw an error if char is out of range 0xFF', function () {
var err1, err2;
var data = 'I ♡ Unicode!';
try {
window.btoa(data);
} catch (e) {
err1 = e;
}
try {
__btoa(data);
} catch (e) {
err2 = e;
}
validateInvalidCharacterError(err1);
validateInvalidCharacterError(err2);
});
});