mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
32 lines
652 B
JavaScript
32 lines
652 B
JavaScript
'use strict';
|
|
|
|
const test = require('tape');
|
|
const diff = require('sinon-called-with-diff');
|
|
const sinon = diff(require('sinon'));
|
|
|
|
const btoa = require('../../common/btoa');
|
|
|
|
test('btoa: browser', (t) => {
|
|
const btoaOriginal = global.btoa;
|
|
const str = 'hello';
|
|
|
|
global.btoa = sinon.stub();
|
|
|
|
btoa(str);
|
|
|
|
t.ok(global.btoa.calledWith(str), 'should call global.btoa');
|
|
t.end();
|
|
|
|
global.btoa = btoaOriginal;
|
|
});
|
|
|
|
test('btoa: node', (t) => {
|
|
const str = 'hello';
|
|
const expected = 'aGVsbG8=';
|
|
|
|
const result = btoa(str);
|
|
|
|
t.equal(result, expected, 'should encode base64');
|
|
t.end();
|
|
});
|
|
|