UNPKG

openapi-modifier

Version:

This package allows you to automate the process of modifying OpenAPI specifications by applying a set of predefined rules

58 lines (57 loc) 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); expect.extend({ toBeCalledLoggerMethod(actual, messageRegExp, count) { var _a; const expectedCount = typeof count === 'number' ? count : 1; let actualCount = 0; const calls = ((_a = actual === null || actual === void 0 ? void 0 : actual.mock) === null || _a === void 0 ? void 0 : _a.calls) || []; calls.forEach((parameters) => { parameters.forEach((parameter) => { if (typeof parameter === 'string' && messageRegExp.test(parameter)) { actualCount++; } }); }); const pass = actualCount === expectedCount; return { pass, message: pass ? () => `expected number of logger method calls ${actualCount} not to be ${expectedCount} with message like "${messageRegExp}"` : () => `expected number of logger method calls ${actualCount} to be ${expectedCount} with message like "${messageRegExp}"`, }; }, }); global.createFakeLogger = () => { const logger = { trace: jest.fn(() => { }), info: jest.fn(() => { }), notImportantWarning: jest.fn(() => { }), warning: jest.fn(() => { }), error: jest.fn(() => { }), errorMessage: jest.fn(() => { }), success: jest.fn(() => { }), helpInfo: jest.fn(() => { }), clone: jest.fn(() => { return logger; }), getHelpInfo: jest.fn(() => ''), }; return logger; }; global.createFakeOpenAPIFile = (document) => { return { context: { sourcePath: '', sourceExtension: '.json', }, // @ts-expect-error wrong OpenAPI type document: Object.assign({ openapi: '3.0.0', info: { version: '1.0.0', title: 'Fake Test OpenAPI', license: { name: 'MIT', }, } }, document), }; };