minor adjustment to readme
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / js-base64 / test / atob.js
1 /*
2  * use mocha to test me
3  * http://visionmedia.github.com/mocha/
4  */
5 var assert = assert || require("assert");
6 var Base64 = Base64 || require('../base64.js').Base64;
7 var is = function (a, e, m) {
8     return function () {
9         assert.equal(a, e, m)
10     }
11 };
12
13 describe('atob', function () {
14
15     describe('basic', function () {
16         it('d',    is(Base64.btoa('d'),    'ZA=='));
17         it('da',   is(Base64.btoa('da'),   'ZGE='));
18         it('dan',  is(Base64.btoa('dan'),  'ZGFu'));
19         it('ZA==', is(Base64.atob('ZA=='), 'd'   ));
20         it('ZGE=', is(Base64.atob('ZGE='), 'da'  ));
21         it('ZGFu', is(Base64.atob('ZGFu'), 'dan' ));
22     });
23
24     describe('whitespace', function () {
25         it('Z A==', is(Base64.atob('ZA =='), 'd'   ));
26         it('ZG E=', is(Base64.atob('ZG E='), 'da'  ));
27         it('ZGF u', is(Base64.atob('ZGF u'), 'dan' ));
28     });
29
30     describe('null', function () {
31         it('\\0',       is(Base64.btoa('\0'),     'AA=='));
32         it('\\0\\0',    is(Base64.btoa('\0\0'),   'AAA='));
33         it('\\0\\0\\0', is(Base64.btoa('\0\0\0'), 'AAAA'));
34         it('AA==',      is(Base64.atob('AA=='), '\0'    ));
35         it('AAA=',      is(Base64.atob('AAA='), '\0\0'  ));
36         it('AAAA',      is(Base64.atob('AAAA'), '\0\0\0'));
37     });
38
39     describe('binary', function () {
40         var pngBase64 = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
41         var pngBinary = '\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\x00\x00\x01\x00\x00\x00\x01\x08\x04\x00\x00\x00\xb5\x1c\x0c\x02\x00\x00\x00\x0b\x49\x44\x41\x54\x78\xda\x63\x64\x60\x00\x00\x00\x06\x00\x02\x30\x81\xd0\x2f\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82';
42         it('.btoa', is(Base64.btoa(pngBinary), pngBase64));
43         it('.atob', is(Base64.atob(pngBase64), pngBinary));
44     });
45
46 });