mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
Better tests for btoa
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
var __btoa = require('../../../lib/helpers/btoa');
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
expect(err1.message).toEqual(err2.message);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user