initial commit
[squeep-mystery-box] / test / lib / common.js
1 /* eslint-env mocha */
2 'use strict';
3
4 const assert = require('assert');
5 const common = require('../../lib/common');
6
7 describe('Common', function () {
8
9 describe('fileScope', function () {
10 it('names a file path', function () {
11 const filename = 'lib/foo/bar.js';
12 const result = common.fileScope(filename)('baz');
13 assert.strictEqual(result, 'bar:baz');
14 });
15 it('names an index path', function () {
16 const filename = 'lib/foo/index.js';
17 const result = common.fileScope(filename)('baz');
18 assert.strictEqual(result, 'foo:baz');
19 });
20 }); // fileScope
21
22 describe('base64ToBase64URL', function () {
23 it('covers', function () {
24 const b64 = '/+==';
25 const expected = '_-';
26 const result = common.base64ToBase64URL(b64);
27 assert.strictEqual(result, expected);
28 });
29 }); // base64ToBase64URL
30
31 describe('base64URLToBase64', function () {
32 it('covers', function () {
33 const b64url = '_-';
34 const expected = '/+==';
35 const result = common.base64URLToBase64(b64url);
36 assert.strictEqual(result, expected);
37 });
38 }); // base64URLToBase64
39
40 describe('base64RePad', function () {
41 it('covers', function () {
42 const b64short = 'af';
43 const expected = 'af==';
44 const result = common.base64RePad(b64short);
45 assert.strictEqual(result, expected);
46 });
47 it('covers padded', function () {
48 const b64 = 'afd4';
49 const expected = b64;
50 const result = common.base64RePad(b64);
51 assert.strictEqual(result, expected);
52 });
53 }); // base64RePad
54
55 }); // Common