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('pick', function () {
22 it('picks', function () {
28 const result
= common
.pick(srcObj
, ['a', 'c', 'd']);
29 assert
.deepStrictEqual(result
, {
36 describe('logTruncate', function () {
37 it('returns short string', function () {
38 const str
= 'this is a short string';
39 const result
= common
.logTruncate(str
, 100);
40 assert
.strictEqual(result
, str
);
42 it('truncates long string', function () {
43 const str
= 'this is not really a very long string but it is long enough for this test';
44 const result
= common
.logTruncate(str
, 10);
45 assert(result
.length
< str
.length
);
49 describe('axiosResponseLogData', function () {
50 it('covers', function () {
55 'Content-Type': 'text/plain',
58 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.”',
64 'Content-Type': 'text/plain',
66 data: 'Old Mother West Wind had stopped to talk with the Slender Fir Tree. "I\'ve just come across the Green... (184 bytes)',
68 const result
= common
.axiosResponseLogData(response
);
69 assert
.deepStrictEqual(result
, expected
);
71 it('covers no data', function () {
76 'Content-Type': 'text/plain',
83 'Content-Type': 'text/plain',
86 const result
= common
.axiosResponseLogData(response
);
87 assert
.deepStrictEqual(result
, expected
);
89 }); // axiosResponseLogData
91 describe('setSymmetricDifference', function () {
92 it('covers difference', function () {
93 const setA
= new Set([1, 2, 3]);
94 const setB
= new Set([2, 3, 4]);
95 const expected
= new Set([1, 4]);
96 const result
= common
.setSymmetricDifference(setA
, setB
);
98 assert
.deepStrictEqual(result
, expected
);
100 it('covers no difference', function () {
101 const setA
= new Set([1, 2, 3, 4]);
102 const setB
= new Set([1, 2, 3, 4]);
103 const expected
= new Set();
104 const result
= common
.setSymmetricDifference(setA
, setB
);
105 assert(!result
.size
);
106 assert
.deepStrictEqual(result
, expected
);
108 }); // setSymmetricDifference
110 describe('properURLComponentName', function () {
111 it('maps proper names', function () {
113 ['hash', 'fragment'],
114 ['protocol', 'scheme'],
116 ].forEach(([name
, expected
]) => {
117 const result
= common
.properURLComponentName(name
);
118 assert
.strictEqual(result
, expected
);
121 }); // properURLComponentName