From c69df062466e1dcff929e0a15785f9f6e81993f9 Mon Sep 17 00:00:00 2001 From: michalholasek Date: Wed, 22 Nov 2017 16:02:08 +0100 Subject: [PATCH] chore: Make eslint dance on the test files again --- test/fixtures/index.js | 55 ++++-------- test/schemas/annotation.js | 9 +- test/schemas/compilation-result.js | 30 +++---- test/schemas/location.js | 24 +++--- test/schemas/origin.js | 7 +- test/schemas/path-origin.js | 28 +++---- test/unit/compile-uri/compile-params-test.js | 34 ++++---- .../compile-uri/expand-uri-template-test.js | 83 +++++++++---------- .../compile-uri/validate-parameters-test.js | 40 ++++----- test/utils.js | 27 +++--- 10 files changed, 131 insertions(+), 206 deletions(-) diff --git a/test/fixtures/index.js b/test/fixtures/index.js index 9274963..77bfe88 100644 --- a/test/fixtures/index.js +++ b/test/fixtures/index.js @@ -1,65 +1,45 @@ -/* eslint-disable - consistent-return, - func-names, - max-len, - no-restricted-syntax, - no-shadow, - one-var, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. - const fs = require('fs'); const path = require('path'); -const zoo = require('swagger-zoo'); +const zoo = require('swagger-zoo'); -const fromSwaggerZoo = function (name) { - for (const feature of zoo.features()) { - if (feature.name === name) { return feature.swagger; } - } -}; - +function fromSwaggerZoo(name) { + return zoo.features().reduce((result, feature) => { + if (feature.name === name) return Object.assign({}, { value: feature.swagger }); + return result; + }, {}).value; // Actual result (feature.swagger) +} const fromFile = filename => fs.readFileSync(path.join(__dirname, filename)).toString(); - const FORMAT_NAMES = { apiBlueprint: 'API Blueprint', swagger: 'Swagger' }; - // Fixture factory. Makes sure the fixtures are available both as an iterable // array as well as name/source mapping. -const fixture = function (apiDescriptions) { +function fixture(apiDescriptions = {}) { // The fixture is an array - let name, - source; - const fix = ((() => { - const result = []; - - for (name of Object.keys(apiDescriptions || {})) { - source = apiDescriptions[name]; - result.push({ format: FORMAT_NAMES[name], source }); - } - - return result; - })()); + const fix = Object.keys(apiDescriptions).map(apiDescription => ({ + format: FORMAT_NAMES[apiDescription], + source: apiDescriptions[apiDescription] + })); // At the same time, it is an object so we can access specific format as // an object property - for (name of Object.keys(apiDescriptions || {})) { source = apiDescriptions[name]; fix[name] = source; } + Object.keys(apiDescriptions).forEach((apiDescription) => { + fix[apiDescription] = apiDescriptions[apiDescription]; + }); // And this is handy helper for tests - fix.forEachDescribe = function (fn) { + fix.forEachDescribe = function forEachDescribe(fn) { return this.forEach(({ format, source }) => describe(format, () => fn({ format, source }))); }; return fix; -}; - +} // Collection of API description fixtures. To iterate over all available formats // of specific fixture (e.g. `parserError`), use: @@ -213,5 +193,4 @@ const fixtures = { }) }; - module.exports = fixtures; diff --git a/test/schemas/annotation.js b/test/schemas/annotation.js index 183ce56..cc673ad 100644 --- a/test/schemas/annotation.js +++ b/test/schemas/annotation.js @@ -1,17 +1,10 @@ -/* eslint-disable - func-names, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. const createLocationSchema = require('./location'); const createOriginSchema = require('./origin'); - const TYPES = ['error', 'warning']; const COMPONENTS = ['apiDescriptionParser', 'parametersValidation', 'uriTemplateExpansion']; - -module.exports = function (options = {}) { +module.exports = function createAnnotationSchema(options = {}) { // Either filename string or undefined (= doesn't matter) const { filename } = options; diff --git a/test/schemas/compilation-result.js b/test/schemas/compilation-result.js index 63d3be2..c758ba9 100644 --- a/test/schemas/compilation-result.js +++ b/test/schemas/compilation-result.js @@ -1,28 +1,22 @@ -/* eslint-disable - func-names, - no-param-reassign, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. const createOriginSchema = require('./origin'); const createPathOriginSchema = require('./path-origin'); const createAnnotationSchema = require('./annotation'); +function addMinMax(schema, n) { + const modifiedSchema = Object.assign({}, schema); -const addMinMax = function (schema, n) { if (n.length === 1) { // [min] - schema.minItems = n[0]; + modifiedSchema.minItems = n[0]; } else if (n.length === 2) { // [min, max] - [schema.minItems, schema.maxItems] = Array.from(n); + [modifiedSchema.minItems, modifiedSchema.maxItems] = Array.from(n); } else { // exact number - schema.minItems = n; - schema.maxItems = n; + modifiedSchema.minItems = n; + modifiedSchema.maxItems = n; } - return schema; -}; - + return modifiedSchema; +} -module.exports = function (options = {}) { +module.exports = function createCompilationResultSchema(options = {}) { // Either filename string or undefined (= doesn't matter) const { filename } = options; @@ -82,14 +76,12 @@ module.exports = function (options = {}) { const transactionsSchema = addMinMax({ type: 'array', items: transactionSchema - } - , transactions); + }, transactions); const annotationsSchema = addMinMax({ type: 'array', items: createAnnotationSchema({ filename }) - } - , annotations); + }, annotations); return { type: 'object', diff --git a/test/schemas/location.js b/test/schemas/location.js index efcbc2a..6c1c45f 100644 --- a/test/schemas/location.js +++ b/test/schemas/location.js @@ -1,15 +1,11 @@ -// TODO: This file was created by bulk-decaffeinate. -// Sanity-check the conversion and remove this comment. -module.exports = () => - ({ +module.exports = () => ({ + type: 'array', + items: { type: 'array', - items: { - type: 'array', - items: [ - { type: 'number' }, - { type: 'number' } - ], - additionalItems: false - } - }) -; + items: [ + { type: 'number' }, + { type: 'number' } + ], + additionalItems: false + } +}); diff --git a/test/schemas/origin.js b/test/schemas/origin.js index 9001be3..9348acc 100644 --- a/test/schemas/origin.js +++ b/test/schemas/origin.js @@ -1,9 +1,4 @@ -/* eslint-disable - func-names, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -module.exports = function (options = {}) { +module.exports = function createOriginSchema(options = {}) { let filenameSchema; if (options.filename) { filenameSchema = { type: 'string', enum: [options.filename] }; diff --git a/test/schemas/path-origin.js b/test/schemas/path-origin.js index 5d73f38..4e0ee08 100644 --- a/test/schemas/path-origin.js +++ b/test/schemas/path-origin.js @@ -1,16 +1,12 @@ -// TODO: This file was created by bulk-decaffeinate. -// Sanity-check the conversion and remove this comment. -module.exports = () => - ({ - type: 'object', - properties: { - apiName: { type: 'string' }, - resourceGroupName: { type: 'string' }, - resourceName: { type: 'string' }, - actionName: { type: 'string' }, - exampleName: { type: 'string' } - }, - required: ['apiName', 'resourceGroupName', 'resourceName', 'actionName', 'exampleName'], - additionalProperties: false - }) -; +module.exports = () => ({ + type: 'object', + properties: { + apiName: { type: 'string' }, + resourceGroupName: { type: 'string' }, + resourceName: { type: 'string' }, + actionName: { type: 'string' }, + exampleName: { type: 'string' } + }, + required: ['apiName', 'resourceGroupName', 'resourceName', 'actionName', 'exampleName'], + additionalProperties: false +}); diff --git a/test/unit/compile-uri/compile-params-test.js b/test/unit/compile-uri/compile-params-test.js index 55fd8e4..48eb99a 100644 --- a/test/unit/compile-uri/compile-params-test.js +++ b/test/unit/compile-uri/compile-params-test.js @@ -1,12 +1,6 @@ -/* eslint-disable - new-cap, - no-new-require, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. const { assert } = require('chai'); -const fury = new require('fury'); +const fury = require('fury'); const compileParams = require('../../../src/compile-uri/compile-params'); @@ -17,7 +11,7 @@ describe('compileParams', () => { const parameters = compileParams(hrefVariables); - return assert.deepEqual(parameters, { + assert.deepEqual(parameters, { name: { default: undefined, example: undefined, @@ -34,7 +28,7 @@ describe('compileParams', () => { const parameters = compileParams(hrefVariables); - return assert.deepEqual(parameters, { + assert.deepEqual(parameters, { name: { default: undefined, example: 'Doe', @@ -50,7 +44,7 @@ describe('compileParams', () => { const parameters = compileParams(hrefVariables); - return assert.deepEqual(parameters, { + assert.deepEqual(parameters, { name: { default: undefined, example: 'Doe', @@ -67,7 +61,7 @@ describe('compileParams', () => { const parameters = compileParams(hrefVariables); - return assert.deepEqual(parameters, { + assert.deepEqual(parameters, { name: { default: 'Unknown', example: undefined, @@ -83,7 +77,7 @@ describe('compileParams', () => { const parameters = compileParams(hrefVariables); - return assert.deepEqual(parameters, { + assert.deepEqual(parameters, { names: { default: undefined, example: [], @@ -99,7 +93,7 @@ describe('compileParams', () => { const parameters = compileParams(hrefVariables); - return assert.deepEqual(parameters, { + assert.deepEqual(parameters, { names: { default: undefined, example: ['One', 'Two'], @@ -116,7 +110,7 @@ describe('compileParams', () => { const parameters = compileParams(hrefVariables); - return assert.deepEqual(parameters, { + assert.deepEqual(parameters, { names: { default: ['Unknown'], example: [], @@ -132,7 +126,7 @@ describe('compileParams', () => { const parameters = compileParams(hrefVariables); - return assert.deepEqual(parameters, { + assert.deepEqual(parameters, { names: { default: undefined, example: ['One', 'Two'], @@ -149,7 +143,7 @@ describe('compileParams', () => { const parameters = compileParams(hrefVariables); - return assert.deepEqual(parameters, { + assert.deepEqual(parameters, { names: { default: ['Unknown'], example: [], @@ -168,7 +162,7 @@ describe('compileParams', () => { const parameters = compileParams(hrefVariables); - return assert.deepEqual(parameters, { + assert.deepEqual(parameters, { order: { default: undefined, example: 'ascending', @@ -187,7 +181,7 @@ describe('compileParams', () => { const parameters = compileParams(hrefVariables); - return assert.deepEqual(parameters, { + assert.deepEqual(parameters, { order: { default: undefined, example: 'decending', @@ -197,7 +191,7 @@ describe('compileParams', () => { }); }); - return it('should compile an enum href variable with default', () => { + it('should compile an enum href variable with default', () => { const hrefVariables = new fury.minim.elements.HrefVariables(); const value = new fury.minim.elements.Element(); value.element = 'enum'; @@ -207,7 +201,7 @@ describe('compileParams', () => { const parameters = compileParams(hrefVariables); - return assert.deepEqual(parameters, { + assert.deepEqual(parameters, { order: { default: 'decending', example: 'ascending', diff --git a/test/unit/compile-uri/expand-uri-template-test.js b/test/unit/compile-uri/expand-uri-template-test.js index 6f46bb3..89b8e02 100644 --- a/test/unit/compile-uri/expand-uri-template-test.js +++ b/test/unit/compile-uri/expand-uri-template-test.js @@ -1,9 +1,3 @@ -/* eslint-disable - no-dupe-keys, - no-return-assign, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. const { assert } = require('chai'); const expandUriTemplate = require('../../../src/compile-uri/expand-uri-template'); @@ -25,12 +19,12 @@ describe('expandUriTemplate', () => { } }; - return data = expandUriTemplate(uriTemplate, parameters); + data = expandUriTemplate(uriTemplate, parameters); }); it('should return an object', () => assert.isObject(data)); - return describe('returned obejct', () => { + describe('returned obejct', () => { [ 'errors', 'warnings', @@ -52,10 +46,10 @@ describe('expandUriTemplate', () => { } }; - return data = expandUriTemplate(uriTemplate, parameters); + data = expandUriTemplate(uriTemplate, parameters); }); - return it('it should return some errror', () => assert.notEqual(data.errors.length, 0)); + it('it should return some errror', () => assert.notEqual(data.errors.length, 0)); }); @@ -63,7 +57,7 @@ describe('expandUriTemplate', () => { before(() => { uriTemplate = '/machines/waldo'; parameters = {}; - return data = expandUriTemplate(uriTemplate, parameters); + data = expandUriTemplate(uriTemplate, parameters); }); describe('with no parameters given', () => { @@ -71,11 +65,11 @@ describe('expandUriTemplate', () => { it('should return no warning', () => assert.equal(data.warnings.length, 0)); - return it('should return URI as it is', () => assert.equal(data.uri, uriTemplate)); + it('should return URI as it is', () => assert.equal(data.uri, uriTemplate)); }); - return describe('with some parameters given', () => { + describe('with some parameters given', () => { before(() => { uriTemplate = '/machines/waldo'; parameters = { @@ -88,7 +82,7 @@ describe('expandUriTemplate', () => { } }; - return data = expandUriTemplate(uriTemplate, parameters); + data = expandUriTemplate(uriTemplate, parameters); }); it('should return no error', () => assert.equal(data.errors.length, 0)); @@ -99,34 +93,34 @@ describe('expandUriTemplate', () => { assert.equal(data.warnings.length, 0) ); - return it('should return URI as it is', () => assert.equal(data.uri, uriTemplate)); + it('should return URI as it is', () => assert.equal(data.uri, uriTemplate)); }); }); - return describe('when UriTemplate with some URI template expression given', () => { + describe('when UriTemplate with some URI template expression given', () => { describe('when no matching parameters provided', () => { before(() => { uriTemplate = '/machines/{name}'; parameters = {}; - return data = expandUriTemplate(uriTemplate, parameters); + data = expandUriTemplate(uriTemplate, parameters); }); it('should return some warning', () => assert.notEqual(data.warnings.length, 0)); describe('returned warning', () => { let warning = ''; - before(() => warning = data.warnings[data.warnings.length - 1]); + before(() => { warning = data.warnings[data.warnings.length - 1]; }); - return it('should contain proper text', () => { + it('should contain proper text', () => { const text = 'Parameter not defined'; - return assert.include(warning, text); + assert.include(warning, text); }); }); it('should return no error', () => assert.equal(data.errors.length, 0)); - return it('should return no URI', () => assert.equal(data.uri, null)); + it('should return no URI', () => assert.equal(data.uri, null)); }); describe('with defined some parameters not matching any expression', () => { @@ -141,7 +135,6 @@ describe('expandUriTemplate', () => { default: '' }, fanny: { - required: false, description: 'Machine fanny', type: 'string', required: true, @@ -150,7 +143,7 @@ describe('expandUriTemplate', () => { } }; - return data = expandUriTemplate(uriTemplate, parameters); + data = expandUriTemplate(uriTemplate, parameters); }); it('should return no error', () => assert.equal(data.errors.length, 0)); @@ -161,7 +154,7 @@ describe('expandUriTemplate', () => { assert.equal(data.warnings.length, 0) ); - return it('should return expandend URI', () => assert.equal(data.uri, '/machines/waldo')); + it('should return expandend URI', () => assert.equal(data.uri, '/machines/waldo')); }); describe('when expression parameter is required', () => { @@ -178,7 +171,7 @@ describe('expandUriTemplate', () => { } }; - return data = expandUriTemplate(uriTemplate, parameters); + data = expandUriTemplate(uriTemplate, parameters); }); it('should return no error', () => assert.equal(data.errors.length, 0)); @@ -187,13 +180,13 @@ describe('expandUriTemplate', () => { it('should return no URI', () => assert.isNull(data.uri)); - return describe('returned warning', () => { + describe('returned warning', () => { let warning = ''; - before(() => warning = data.warnings[data.warnings.length - 1]); + before(() => { warning = data.warnings[data.warnings.length - 1]; }); - return it('should contain proper text', () => { + it('should contain proper text', () => { const text = 'No example value for required parameter'; - return assert.include(warning, text); + assert.include(warning, text); }); }); }); @@ -211,7 +204,7 @@ describe('expandUriTemplate', () => { } }; - return data = expandUriTemplate(uriTemplate, parameters); + data = expandUriTemplate(uriTemplate, parameters); }); it('should return no error', () => assert.equal(data.errors.length, 0)); @@ -220,7 +213,7 @@ describe('expandUriTemplate', () => { it('should use example value to URI parameter expansion', () => assert.include(data.uri, parameters.name.example)); - return it('should return URI', () => assert.isNotNull(data.uri)); + it('should return URI', () => assert.isNotNull(data.uri)); }); describe('when default value is given', () => { @@ -236,7 +229,7 @@ describe('expandUriTemplate', () => { } }; - return data = expandUriTemplate(uriTemplate, parameters); + data = expandUriTemplate(uriTemplate, parameters); }); it('should return no error', () => assert.equal(data.errors.length, 0)); @@ -247,10 +240,10 @@ describe('expandUriTemplate', () => { it('should use default value to URI parameter expansion', () => assert.include(data.uri, parameters.name.default)); - return it('should return URI', () => assert.isNotNull(data.uri)); + it('should return URI', () => assert.isNotNull(data.uri)); }); - return describe('when example and default values are given', () => { + describe('when example and default values are given', () => { before(() => { uriTemplate = '/machines/{name}'; parameters = { @@ -263,7 +256,7 @@ describe('expandUriTemplate', () => { } }; - return data = expandUriTemplate(uriTemplate, parameters); + data = expandUriTemplate(uriTemplate, parameters); }); it('should return no error', () => assert.equal(data.errors.length, 0)); @@ -274,11 +267,11 @@ describe('expandUriTemplate', () => { it('should use example value to URI parameter expansion', () => assert.include(data.uri, parameters.name.example)); - return it('should return URI', () => assert.isNotNull(data.uri)); + it('should return URI', () => assert.isNotNull(data.uri)); }); }); - return describe('when expression parameter is optional', () => { + describe('when expression parameter is optional', () => { before(() => { uriTemplate = '/machines/{name}'; parameters = { @@ -291,7 +284,7 @@ describe('expandUriTemplate', () => { } }; - return data = expandUriTemplate(uriTemplate, parameters); + data = expandUriTemplate(uriTemplate, parameters); }); it('should return no error', () => assert.equal(data.errors.length, 0)); @@ -315,7 +308,7 @@ describe('expandUriTemplate', () => { } }; - return data = expandUriTemplate(uriTemplate, parameters); + data = expandUriTemplate(uriTemplate, parameters); }); it('should return no error', () => assert.equal(data.errors.length, 0)); @@ -324,7 +317,7 @@ describe('expandUriTemplate', () => { it('should use default value to URI parameter expansion', () => assert.include(data.uri, parameters.name.default)); - return it('should return URI', () => assert.isNotNull(data.uri)); + it('should return URI', () => assert.isNotNull(data.uri)); }); describe('when example and default values are given', () => { @@ -340,7 +333,7 @@ describe('expandUriTemplate', () => { } }; - return data = expandUriTemplate(uriTemplate, parameters); + data = expandUriTemplate(uriTemplate, parameters); }); it('should return no error', () => assert.equal(data.errors.length, 0)); @@ -349,10 +342,10 @@ describe('expandUriTemplate', () => { it('should use example value to URI parameter expansion', () => assert.include(data.uri, parameters.name.example)); - return it('should return some URI', () => assert.isNotNull(data.uri)); + it('should return some URI', () => assert.isNotNull(data.uri)); }); - return describe('when example and default values are not given', () => { + describe('when example and default values are not given', () => { before(() => { uriTemplate = '/machines/{name}'; parameters = { @@ -365,14 +358,14 @@ describe('expandUriTemplate', () => { } }; - return data = expandUriTemplate(uriTemplate, parameters); + data = expandUriTemplate(uriTemplate, parameters); }); it('should return no error', () => assert.equal(data.errors.length, 0)); it('should return no warning', () => assert.equal(data.warnings.length, 0)); - return it('should return some URI', () => assert.isNotNull(data.uri)); + it('should return some URI', () => assert.isNotNull(data.uri)); }); }); }); diff --git a/test/unit/compile-uri/validate-parameters-test.js b/test/unit/compile-uri/validate-parameters-test.js index e69e9da..934a7f2 100644 --- a/test/unit/compile-uri/validate-parameters-test.js +++ b/test/unit/compile-uri/validate-parameters-test.js @@ -1,9 +1,3 @@ -/* eslint-disable - no-return-assign, - no-unused-vars, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. const { assert } = require('chai'); const validateParams = require('../../../src/compile-uri/validate-params'); @@ -22,7 +16,7 @@ describe('validateParams', () => { }; const result = validateParams(params); - return assert.isObject(result); + assert.isObject(result); }); describe('when type is string and example is a parseable float', () => @@ -39,8 +33,7 @@ describe('validateParams', () => { }; const result = validateParams(params); - const message = result.errors[0]; - return assert.equal(result.errors.length, 0); + assert.equal(result.errors.length, 0); }) ); @@ -48,7 +41,6 @@ describe('validateParams', () => { // https://github.com/apiaryio/dredd/issues/106 describe('when type is string and example is a string but starting with a number', () => it('should set no error', () => { - let result; const params = { name: { description: 'Machine name', @@ -60,7 +52,7 @@ describe('validateParams', () => { } }; - return result = validateParams(params); + validateParams(params); }) ); @@ -78,7 +70,7 @@ describe('validateParams', () => { }; const result = validateParams(params); - return assert.equal(result.errors.length, 0); + assert.equal(result.errors.length, 0); }) ); @@ -98,7 +90,7 @@ describe('validateParams', () => { const result = validateParams(params); const message = result.errors[0]; assert.include(message, 'name'); - return assert.include(message, 'number'); + assert.include(message, 'number'); }) ); @@ -116,7 +108,7 @@ describe('validateParams', () => { }; const result = validateParams(params); - return assert.equal(result.errors.length, 0); + assert.equal(result.errors.length, 0); }) ); @@ -136,7 +128,7 @@ describe('validateParams', () => { const result = validateParams(params); const message = result.errors[0]; assert.include(message, 'name'); - return assert.include(message, 'enum'); + assert.include(message, 'enum'); }) ); @@ -154,7 +146,7 @@ describe('validateParams', () => { }; const result = validateParams(params); - return assert.equal(result.errors.length, 0); + assert.equal(result.errors.length, 0); }) ); @@ -174,7 +166,7 @@ describe('validateParams', () => { const result = validateParams(params); const message = result.errors[0]; assert.include(message, 'name'); - return assert.include(message, 'boolean'); + assert.include(message, 'boolean'); }) ); @@ -192,7 +184,7 @@ describe('validateParams', () => { }; const result = validateParams(params); - return assert.equal(result.errors.length, 0); + assert.equal(result.errors.length, 0); }) ); @@ -213,7 +205,7 @@ describe('validateParams', () => { const result = validateParams(params); const message = result.errors[0]; assert.include(message, 'name'); - return assert.include(message, 'Required'); + assert.include(message, 'Required'); }) ); @@ -231,7 +223,7 @@ describe('validateParams', () => { }; const result = validateParams(params); - return assert.equal(result.errors.length, 0); + assert.equal(result.errors.length, 0); }) ); @@ -249,7 +241,7 @@ describe('validateParams', () => { }; const result = validateParams(params); - return assert.equal(result.errors.length, 0); + assert.equal(result.errors.length, 0); }) ); }); @@ -269,7 +261,7 @@ describe('validateParams', () => { }; const result = validateParams(params); - return assert.equal(result.errors.length, 0); + assert.equal(result.errors.length, 0); }) ); @@ -288,7 +280,7 @@ describe('validateParams', () => { }; const result = validateParams(params); - return assert.equal(result.errors.length, 0); + assert.equal(result.errors.length, 0); }) ); @@ -306,7 +298,7 @@ describe('validateParams', () => { }; const result = validateParams(params); - return assert.equal(result.errors.length, 0); + assert.equal(result.errors.length, 0); }) ); }); diff --git a/test/utils.js b/test/utils.js index a3200e4..8a81027 100644 --- a/test/utils.js +++ b/test/utils.js @@ -1,26 +1,23 @@ -/* eslint-disable - func-names, - global-require, - no-param-reassign, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. const chai = require('chai'); -chai.use(require('chai-json-schema')); const proxyquire = require('proxyquire').noPreserveCache(); +const nativeCompile = require('../src/compile'); const parse = require('../src/parse'); +chai.use(require('chai-json-schema')); // Takes a fixture and parses it so we can test the compilation process. -const compileFixture = function (source, options, done) { +function compileFixture(source, options, done) { let compile; - if (typeof options === 'function') { [done, options] = Array.from([options, {}]); } + + if (typeof options === 'function') { + [done, options] = Array.from([options, {}]); // eslint-disable-line no-param-reassign + } if (options.stubs) { compile = proxyquire('../src/compile', options.stubs); } else { - compile = require('../src/compile'); + compile = nativeCompile; } return parse(source, (err, parseResult) => { @@ -32,11 +29,9 @@ const compileFixture = function (source, options, done) { const result = compile(mediaType, apiElements, options.filename); return done(null, result); } catch (error) { - err = error; - return done(err); + return done(error); } }); -}; - +} -module.exports = { compileFixture, assert: chai.assert }; +module.exports = { assert: chai.assert, compileFixture };