f5df10c779e1054b0881d701e382f4164f53ab1d
[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 it('covers empty', function () {
30 const result = common.base64ToBase64URL(undefined);
31 assert.strictEqual(result, undefined);
32 });
33 }); // base64ToBase64URL
34
35 describe('base64URLToBase64', function () {
36 it('covers', function () {
37 const b64url = '_-';
38 const expected = '/+==';
39 const result = common.base64URLToBase64(b64url);
40 assert.strictEqual(result, expected);
41 });
42 it('covers empty', function () {
43 const result = common.base64URLToBase64(undefined);
44 assert.strictEqual(result, undefined);
45 });
46 }); // base64URLToBase64
47
48 describe('base64RePad', function () {
49 it('covers', function () {
50 const b64short = 'af';
51 const expected = 'af==';
52 const result = common.base64RePad(b64short);
53 assert.strictEqual(result, expected);
54 });
55 it('covers padded', function () {
56 const b64 = 'afd4';
57 const expected = b64;
58 const result = common.base64RePad(b64);
59 assert.strictEqual(result, expected);
60 });
61 }); // base64RePad
62
63 }); // Common