2
0
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:
Matt Zabriskie
2015-12-14 12:16:57 -07:00
parent 77b8966b47
commit 9ede644b98
4 changed files with 82 additions and 81 deletions
+27
View File
@@ -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);
});
});