8b223dadc0ea9c429d7023f3ba1056f534e12aac
4 const assert
= require('assert');
5 const common
= require('../../lib/common');
7 describe('common', function () {
8 describe('fileScope', function () {
9 it('names a file path', function () {
10 const filename
= 'lib/foo/bar.js';
11 const result
= common
.fileScope(filename
)('baz');
12 assert
.strictEqual(result
, 'bar:baz');
14 it('names an index path', function () {
15 const filename
= 'lib/foo/index.js';
16 const result
= common
.fileScope(filename
)('baz');
17 assert
.strictEqual(result
, 'foo:baz');
21 describe('base64ToBase64URL', function () {
22 it('works', function () {
23 const b64
= 'ab/cd+e=';
24 const expected
= 'ab_cd-e';
25 const result
= common
.base64ToBase64URL(b64
);
26 assert
.strictEqual(result
, expected
);
28 }); // base64ToBase64URL
30 describe('pick', function () {
31 it('picks', function () {
37 const result
= common
.pick(srcObj
, ['a', 'c', 'd']);
38 assert
.deepStrictEqual(result
, {
45 describe('logTruncate', function () {
46 it('returns short string', function () {
47 const str
= 'this is a short string';
48 const result
= common
.logTruncate(str
, 100);
49 assert
.strictEqual(result
, str
);
51 it('truncates long string', function () {
52 const str
= 'this is not really a very long string but it is long enough for this test';
53 const result
= common
.logTruncate(str
, 10);
54 assert(result
.length
< str
.length
);
58 describe('axiosResponseLogData', function () {
59 it('covers', function () {
64 'Content-Type': 'text/plain',
67 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.”',
73 'Content-Type': 'text/plain',
75 data: 'Old Mother West Wind had stopped to talk with the Slender Fir Tree. "I\'ve just come across the Green... (184 bytes)',
77 const result
= common
.axiosResponseLogData(response
);
78 assert
.deepStrictEqual(result
, expected
);
80 it('covers no data', function () {
85 'Content-Type': 'text/plain',
92 'Content-Type': 'text/plain',
95 const result
= common
.axiosResponseLogData(response
);
96 assert
.deepStrictEqual(result
, expected
);
98 }); // axiosResponseLogData