--- /dev/null
+/* eslint-env mocha */
+'use strict';
+
+const assert = require('assert');
+const common = require('../../lib/common');
+
+describe('common', function () {
+ describe('fileScope', function () {
+ it('names a file path', function () {
+ const filename = 'lib/foo/bar.js';
+ const result = common.fileScope(filename)('baz');
+ assert.strictEqual(result, 'bar:baz');
+ });
+ it('names an index path', function () {
+ const filename = 'lib/foo/index.js';
+ const result = common.fileScope(filename)('baz');
+ assert.strictEqual(result, 'foo:baz');
+ });
+ }); // fileScope
+
+ describe('base64ToBase64URL', function () {
+ it('works', function () {
+ const b64 = 'ab/cd+e=';
+ const expected = 'ab_cd-e';
+ const result = common.base64ToBase64URL(b64);
+ assert.strictEqual(result, expected);
+ });
+ }); // base64ToBase64URL
+
+ describe('pick', function () {
+ it('picks', function () {
+ const srcObj = {
+ a: 1,
+ b: 2,
+ c: 3,
+ };
+ const result = common.pick(srcObj, ['a', 'c', 'd']);
+ assert.deepStrictEqual(result, {
+ 'a': 1,
+ 'c': 3,
+ });
+ });
+ }); // pick
+
+ describe('logTruncate', function () {
+ it('returns short string', function () {
+ const str = 'this is a short string';
+ const result = common.logTruncate(str, 100);
+ assert.strictEqual(result, str);
+ });
+ it('truncates long string', function () {
+ const str = 'this is not really a very long string but it is long enough for this test';
+ const result = common.logTruncate(str, 10);
+ assert(result.length < str.length);
+ });
+ }); // logTruncate
+
+ describe('axiosResponseLogData', function () {
+ it('covers', function () {
+ const response = {
+ status: 200,
+ statusText: 'OK',
+ headers: {
+ 'Content-Type': 'text/plain',
+ },
+ otherData: 'blah',
+ data: 'Old Mother West Wind had stopped to talk with the Slender Fir Tree. "I\'ve just come across the Green Meadows," said Old Mother West Wind, “and there I saw the Best Thing in the World.”',
+ };
+ const expected = {
+ status: 200,
+ statusText: 'OK',
+ headers: {
+ 'Content-Type': 'text/plain',
+ },
+ data: 'Old Mother West Wind had stopped to talk with the Slender Fir Tree. "I\'ve just come across the Green... (184 bytes)',
+ };
+ const result = common.axiosResponseLogData(response);
+ assert.deepStrictEqual(result, expected);
+ });
+ it('covers no data', function () {
+ const response = {
+ status: 200,
+ statusText: 'OK',
+ headers: {
+ 'Content-Type': 'text/plain',
+ },
+ };
+ const expected = {
+ status: 200,
+ statusText: 'OK',
+ headers: {
+ 'Content-Type': 'text/plain',
+ },
+ };
+ const result = common.axiosResponseLogData(response);
+ assert.deepStrictEqual(result, expected);
+ });
+ }); // axiosResponseLogData
+
+}); // common
\ No newline at end of file