4 const assert
= require('assert');
5 const sinon
= require('sinon');
6 const stubLogger
= require('../stub-logger');
7 const common
= require('../../lib/common');
9 describe('Common', function () {
11 describe('freezeDeep', function () {
12 it('covers', function () {
19 common
.freezeDeep(obj
);
20 assert
.throws(() => obj
.value
= false, TypeError
);
21 assert
.throws(() => obj
.subObj
.subValue
= false, TypeError
);
25 describe('omit', function () {
26 it('does the expected', function () {
30 quux: { squawk: true },
33 const omitted
= ['foo', 'quux'];
38 const result
= common
.omit(orig
, omitted
);
39 assert
.deepStrictEqual(result
, expected
);
43 describe('mysteryBoxLogger', function () {
45 beforeEach(function () {
47 mbl
= common
.mysteryBoxLogger(stubLogger
, 'test:scope');
49 afterEach(function () {
52 it('covers', function () {
54 packageName: 'fake-mystery-box',
55 packageVersion: '0.0.0',
60 assert(stubLogger
.debug
.called
);
62 }); // mysteryBoxLogger
64 describe('obscureAuthorizationHeader', function () {
65 it('blurs Bearer token', function () {
66 const result
= common
.obscureAuthorizationHeader('Bearer foo');
67 assert
.strictEqual(result
, 'Bearer ***');
69 it('blurs entire string for other', function () {
70 const result
= common
.obscureAuthorizationHeader('abcdef');
71 assert
.strictEqual(result
, '******');
73 it('covers empty string', function () {
75 const result
= common
.obscureAuthorizationHeader(a
);
76 assert
.strictEqual(result
, a
);