3 const assert
= require('node:assert');
4 const sinon
= require('sinon');
5 const stubLogger
= require('../stub-logger');
6 const common
= require('../../lib/common');
8 describe('Common', function () {
10 describe('freezeDeep', function () {
11 it('covers', function () {
18 common
.freezeDeep(obj
);
19 assert
.throws(() => obj
.value
= false, TypeError
);
20 assert
.throws(() => obj
.subObj
.subValue
= false, TypeError
);
24 describe('omit', function () {
25 it('does the expected', function () {
29 quux: { squawk: true },
32 const omitted
= ['foo', 'quux'];
37 const result
= common
.omit(orig
, omitted
);
38 assert
.deepStrictEqual(result
, expected
);
42 describe('mysteryBoxLogger', function () {
44 beforeEach(function () {
46 mbl
= common
.mysteryBoxLogger(stubLogger
, 'test:scope');
48 afterEach(function () {
51 it('covers', function () {
53 packageName: 'fake-mystery-box',
54 packageVersion: '0.0.0',
59 assert(stubLogger
.debug
.called
);
61 }); // mysteryBoxLogger
63 describe('obscureAuthorizationHeader', function () {
64 it('blurs Bearer token', function () {
65 const result
= common
.obscureAuthorizationHeader('Bearer foo');
66 assert
.strictEqual(result
, 'Bearer ***');
68 it('blurs entire string for other', function () {
69 const result
= common
.obscureAuthorizationHeader('abcdef');
70 assert
.strictEqual(result
, '******');
72 it('covers empty string', function () {
74 const result
= common
.obscureAuthorizationHeader(a
);
75 assert
.strictEqual(result
, a
);