X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Flib%2Fcommon.js;h=6140d874bd9ef41a9591c28194ae772f21c1e3d9;hb=97be4c0841f2615651c6cd6fb466aada47773cc4;hp=bacd6be3d54d2aaa7e6b019c98e0e664050392dc;hpb=47f38ca4c67e902ccef0b7114a0d144f476258bd;p=squeep-api-dingus diff --git a/test/lib/common.js b/test/lib/common.js index bacd6be..6140d87 100644 --- a/test/lib/common.js +++ b/test/lib/common.js @@ -9,19 +9,6 @@ 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('generateETag', function () { it('generates a tag from data', function () { const expected = '"RHUvNyculE/SyROjU0LqzN0arxibrlBnazAashP8UGE"'; @@ -128,74 +115,6 @@ describe('common', function () { }); }); // pick - describe('requestLogData', function () { - it('gives data', function () { - const req = { - method: 'GET', - somethingElse: 'blah', - }; - const result = common.requestLogData(req); - assert.deepStrictEqual(result, { - method: 'GET', - }); - }); - }); // requestLogData - - describe('obscureAuthorizationHeader', function () { - it('obscures basic data', function () { - const authHeader = 'Basic Zm9vOmJhcg=='; - const expected = 'Basic ************'; - const result = common.obscureAuthorizationHeader(authHeader); - assert.strictEqual(result, expected); - }); - it('obscures all of other types', function () { - const authHeader = 'someWeirdAuth'; - const expected = '*************'; - const result = common.obscureAuthorizationHeader(authHeader); - assert.strictEqual(result, expected); - }); - it('does nothing when empty', function () { - const authHeader = undefined; - const expected = undefined; - const result = common.obscureAuthorizationHeader(authHeader); - assert.strictEqual(result, expected); - }); - }); // obscureAuthorizationHeader - - describe('scrubHeaderObject', function () { - it('', function () { - const data = { - headers: { - 'foo': 'bar', - 'authorization': 'Basic Zm9vOmJhcg==', - }, - }; - const expected = { - headers: { - 'foo': 'bar', - 'authorization': 'Basic ************', - }, - }; - common.scrubHeaderObject(data); - assert.deepStrictEqual(data, expected); - }); - }); // scrubHeaderObject - - describe('responseLogData', function () { - it('gives data', function () { - const res = { - getHeaders: () => ({}), - statusCode: 200, - blah: 'blah', - }; - const result = common.responseLogData(res); - assert.deepStrictEqual(result, { - headers: {}, - statusCode: 200, - }); - }); - }); // responseLogData - describe('setOptions', function () { it('sets options', function () { const expected = { @@ -298,13 +217,6 @@ describe('common', function () { }); }); // requestId - describe('ensureLoggerLevels', function () { - it('adds missing levels', function () { - const result = common.ensureLoggerLevels(); - assert.deepStrictEqual(result, common.nullLogger); - }); - }); // ensureLoggerLevels - describe('httpStatusCodeClass', function () { it('works', function () { for (const [statusCode, statusClassExpected] of Object.entries({