From 1ef2e54b64cf2a13ebcccd32ca4592c6343e32dc Mon Sep 17 00:00:00 2001 From: Rick Clark Date: Thu, 13 Dec 2018 09:16:10 +0000 Subject: [PATCH] Linting (#6) * Install linting deps * Set linting config * Make linting changes --- .eslintrc.json | 21 ++-- index.js | 66 ++++++---- package-lock.json | 240 +++++++++++++++++++++++++++++++++++++ package.json | 5 + test/requested.test.js | 63 ++++++---- test/requestedWith.test.js | 113 ++++++++++------- 6 files changed, 414 insertions(+), 94 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 055a9fc..0f985de 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,8 +1,15 @@ { - "env": { - "node": true, - "es6": true, - "jest": true - }, - "extends": "eslint:recommended" -} \ No newline at end of file + "env": { + "node": true, + "es6": true, + "jest": true + }, + "extends": ["airbnb-base", "prettier"], + "plugins": ["prettier"], + "rules": { + "prettier/prettier": [ + "error", + { "singleQuote": true, "trailingComma": "all" } + ] + } +} diff --git a/index.js b/index.js index fc3fdf9..da0323f 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,9 @@ -"use strict"; +/* eslint-disable no-underscore-dangle */ const equal = require('deep-equal'); -module.exports = (chai) => { - const Assertion = chai.Assertion; +module.exports = chai => { + const { Assertion } = chai; const MAX_TIMEOUT = 2000; function promisfyNockInterceptor(nock) { @@ -36,36 +36,56 @@ module.exports = (chai) => { function isNock(obj) { if ( - typeof(obj) !== 'object' || - !obj.interceptors || - !obj.interceptors.length) - { + typeof obj !== 'object' || + !obj.interceptors || + !obj.interceptors.length + ) { throw new TypeError('You must provide a valid Nock'); - } + } } - Assertion.addProperty('requested', function () { + Assertion.addProperty('requested', () => { isNock(this._obj); - const assert = (value) => { - this.assert(value, 'expected Nock to have been requested', 'expected Nock to have not been requested'); - } - - return promisfyNockInterceptor(this._obj) - .then( - () => assert(true), - () => assert(false) + const assert = value => { + this.assert( + value, + 'expected Nock to have been requested', + 'expected Nock to have not been requested', ); + }; + + return promisfyNockInterceptor(this._obj).then( + () => assert(true), + () => assert(false), + ); }); - Assertion.addMethod('requestedWith', function (arg) { + Assertion.addMethod('requestedWith', arg => { isNock(this._obj); - return promisfyNockInterceptor(this._obj) - .then((nockRequest) => { + return promisfyNockInterceptor(this._obj).then( + nockRequest => { if (equal(nockRequest, arg)) { - return this.assert(true, null, 'expected Nock to have not been requested with #{exp}', arg); + return this.assert( + true, + null, + 'expected Nock to have not been requested with #{exp}', + arg, + ); } - return this.assert(false, 'expected Nock to have been requested with #{exp}, but was requested with #{act}', 'expected Nock to have not been requested with #{exp}', arg, nockRequest); - },() => this.assert(false, 'expected Nock to have been requested, but it was never called')); + return this.assert( + false, + 'expected Nock to have been requested with #{exp}, but was requested with #{act}', + 'expected Nock to have not been requested with #{exp}', + arg, + nockRequest, + ); + }, + () => + this.assert( + false, + 'expected Nock to have been requested, but it was never called', + ), + ); }); }; diff --git a/package-lock.json b/package-lock.json index c8499a4..92ed264 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1122,6 +1122,12 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, + "contains-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", + "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", + "dev": true + }, "convert-source-map": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz", @@ -1523,6 +1529,189 @@ } } }, + "eslint-config-airbnb-base": { + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-13.1.0.tgz", + "integrity": "sha512-XWwQtf3U3zIoKO1BbHh6aUhJZQweOwSt4c2JrPDg9FP3Ltv3+YfEv7jIDB8275tVnO/qOHbfuYg3kzw6Je7uWw==", + "dev": true, + "requires": { + "eslint-restricted-globals": "^0.1.1", + "object.assign": "^4.1.0", + "object.entries": "^1.0.4" + } + }, + "eslint-config-prettier": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-3.3.0.tgz", + "integrity": "sha512-Bc3bh5bAcKNvs3HOpSi6EfGA2IIp7EzWcg2tS4vP7stnXu/J1opihHDM7jI9JCIckyIDTgZLSWn7J3HY0j2JfA==", + "dev": true, + "requires": { + "get-stdin": "^6.0.0" + } + }, + "eslint-import-resolver-node": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz", + "integrity": "sha512-sfmTqJfPSizWu4aymbPr4Iidp5yKm8yDkHp+Ir3YiTHiiDfxh69mOUsmiqW6RZ9zRXFaF64GtYmN7e+8GHBv6Q==", + "dev": true, + "requires": { + "debug": "^2.6.9", + "resolve": "^1.5.0" + }, + "dependencies": { + "resolve": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", + "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", + "dev": true, + "requires": { + "path-parse": "^1.0.5" + } + } + } + }, + "eslint-module-utils": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.2.0.tgz", + "integrity": "sha1-snA2LNiLGkitMIl2zn+lTphBF0Y=", + "dev": true, + "requires": { + "debug": "^2.6.8", + "pkg-dir": "^1.0.0" + }, + "dependencies": { + "find-up": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "dev": true, + "requires": { + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "dev": true, + "requires": { + "pinkie-promise": "^2.0.0" + } + }, + "pkg-dir": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz", + "integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=", + "dev": true, + "requires": { + "find-up": "^1.0.0" + } + } + } + }, + "eslint-plugin-import": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.14.0.tgz", + "integrity": "sha512-FpuRtniD/AY6sXByma2Wr0TXvXJ4nA/2/04VPlfpmUDPOpOY264x+ILiwnrk/k4RINgDAyFZByxqPUbSQ5YE7g==", + "dev": true, + "requires": { + "contains-path": "^0.1.0", + "debug": "^2.6.8", + "doctrine": "1.5.0", + "eslint-import-resolver-node": "^0.3.1", + "eslint-module-utils": "^2.2.0", + "has": "^1.0.1", + "lodash": "^4.17.4", + "minimatch": "^3.0.3", + "read-pkg-up": "^2.0.0", + "resolve": "^1.6.0" + }, + "dependencies": { + "doctrine": { + "version": "1.5.0", + "resolved": "http://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", + "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "isarray": "^1.0.0" + } + }, + "load-json-file": { + "version": "2.0.0", + "resolved": "http://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "strip-bom": "^3.0.0" + } + }, + "path-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", + "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "dev": true, + "requires": { + "pify": "^2.0.0" + } + }, + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "dev": true, + "requires": { + "load-json-file": "^2.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^2.0.0" + } + }, + "read-pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", + "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "dev": true, + "requires": { + "find-up": "^2.0.0", + "read-pkg": "^2.0.0" + } + }, + "resolve": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", + "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", + "dev": true, + "requires": { + "path-parse": "^1.0.5" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + } + } + }, + "eslint-plugin-prettier": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.0.0.tgz", + "integrity": "sha512-4g11opzhqq/8+AMmo5Vc2Gn7z9alZ4JqrbZ+D4i8KlSyxeQhZHlmIrY8U9Akf514MoEhogPa87Jgkq87aZ2Ohw==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, + "eslint-restricted-globals": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/eslint-restricted-globals/-/eslint-restricted-globals-0.1.1.tgz", + "integrity": "sha1-NfDVy8ZMLj7WLpO0saevBbp+1Nc=", + "dev": true + }, "eslint-scope": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.0.tgz", @@ -1721,6 +1910,12 @@ "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", "dev": true }, + "fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", @@ -2410,6 +2605,12 @@ "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=" }, + "get-stdin": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", + "dev": true + }, "get-stream": { "version": "3.0.0", "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", @@ -4068,6 +4269,30 @@ } } }, + "object.assign": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", + "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.0", + "object-keys": "^1.0.11" + } + }, + "object.entries": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/object.entries/-/object.entries-1.0.4.tgz", + "integrity": "sha1-G/mk3SKI9bM/Opk9JXZh8F0WGl8=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.6.1", + "function-bind": "^1.1.0", + "has": "^1.0.1" + } + }, "object.getownpropertydescriptors": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", @@ -4353,6 +4578,21 @@ "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", "dev": true }, + "prettier": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.15.3.tgz", + "integrity": "sha512-gAU9AGAPMaKb3NNSUUuhhFAS7SCO4ALTN4nRIn6PJ075Qd28Yn2Ig2ahEJWdJwJmlEBTUfC7mMUSFy8MwsOCfg==", + "dev": true + }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, "pretty-format": { "version": "23.6.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-23.6.0.tgz", diff --git a/package.json b/package.json index 3087d0e..d289a1e 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,13 @@ "homepage": "https://github.com/ComparetheMarket/chai-nock#readme", "devDependencies": { "eslint": "^5.9.0", + "eslint-config-airbnb-base": "^13.1.0", + "eslint-config-prettier": "^3.3.0", + "eslint-plugin-import": "^2.14.0", + "eslint-plugin-prettier": "^3.0.0", "jest": "^23.6.0", "nock": "^10.0.2", + "prettier": "^1.15.3", "request": "^2.88.0", "request-promise-native": "^1.0.5" }, diff --git a/test/requested.test.js b/test/requested.test.js index 2216de1..b0940f7 100644 --- a/test/requested.test.js +++ b/test/requested.test.js @@ -1,8 +1,9 @@ -const { expect, use} = require('chai'); +const { expect, use } = require('chai'); const nock = require('nock'); const request = require('request-promise-native'); const chaiNock = require('../'); + use(chaiNock); describe('requested assertions', () => { @@ -14,16 +15,16 @@ describe('requested assertions', () => { describe('when asserting on a type that is not a Nock', () => { it('throws a type error', () => { - expect( - () => expect('NOT_A_NOCK').to.have.been.requested - ).to.throw(TypeError); + expect(() => expect('NOT_A_NOCK').to.have.been.requested).to.throw( + TypeError, + ); - expect( - () => expect({}).to.have.been.requested - ).to.throw(TypeError); + expect(() => expect({}).to.have.been.requested).to.throw(TypeError); expect( - () => expect(nock('http://url-without.a').get('/interceptor')).to.have.been.requested + () => + expect(nock('http://url-without.a').get('/interceptor')).to.have.been + .requested, ).to.throw(TypeError); }); }); @@ -31,7 +32,9 @@ describe('requested assertions', () => { describe('.requested', () => { describe('when a request to the nock has been made', () => { it('passes', () => { - const requestNock = nock(TEST_URL).get('/').reply(200); + const requestNock = nock(TEST_URL) + .get('/') + .reply(200); request(TEST_URL); return expect(requestNock).to.have.been.requested; @@ -39,32 +42,40 @@ describe('requested assertions', () => { }); describe('when a request to the nock has not been made', () => { - it('throws', (done) => { - const requestNock = nock(TEST_URL).get('/').reply(200); + it('throws', done => { + const requestNock = nock(TEST_URL) + .get('/') + .reply(200); const assertion = expect(requestNock).to.have.been.requested; return assertion .then(() => done.fail('Should have thrown an error')) - .catch((err) => { - expect(err.message).to.equal('expected Nock to have been requested'); + .catch(err => { + expect(err.message).to.equal( + 'expected Nock to have been requested', + ); done(); }); }); }); describe('when a there is an error in the nock', () => { - it('throws', (done) => { - const requestNock = nock(TEST_URL).get('/').reply(200); + it('throws', done => { + const requestNock = nock(TEST_URL) + .get('/') + .reply(200); const assertion = expect(requestNock).to.have.been.requested; - requestNock.emit('error', new Error('A problem with Nock')) + requestNock.emit('error', new Error('A problem with Nock')); return assertion .then(() => done.fail('Should have thrown an error')) - .catch((err) => { - expect(err.message).to.equal('expected Nock to have been requested'); + .catch(err => { + expect(err.message).to.equal( + 'expected Nock to have been requested', + ); done(); }); }); @@ -74,23 +85,29 @@ describe('requested assertions', () => { describe('.not.requested', () => { describe('when a request to the nock has not been made', () => { it('passes', () => { - const requestNock = nock(TEST_URL).get('/').reply(200); + const requestNock = nock(TEST_URL) + .get('/') + .reply(200); return expect(requestNock).not.to.have.been.requested; }); }); describe('when a request to the nock has been made', () => { - it('throws', (done) => { - const requestNock = nock(TEST_URL).get('/').reply(200); + it('throws', done => { + const requestNock = nock(TEST_URL) + .get('/') + .reply(200); request(TEST_URL); const assertion = expect(requestNock).not.to.have.been.requested; return assertion .then(() => done.fail('Should have thrown an error')) - .catch((err) => { - expect(err.message).to.equal('expected Nock to have not been requested'); + .catch(err => { + expect(err.message).to.equal( + 'expected Nock to have not been requested', + ); done(); }); }); diff --git a/test/requestedWith.test.js b/test/requestedWith.test.js index c4bc526..93718a6 100644 --- a/test/requestedWith.test.js +++ b/test/requestedWith.test.js @@ -1,8 +1,9 @@ -const { expect, use} = require('chai'); +const { expect, use } = require('chai'); const nock = require('nock'); const request = require('request-promise-native'); const chaiNock = require('../'); + use(chaiNock); describe('requestedWith() assertions', () => { @@ -14,16 +15,16 @@ describe('requestedWith() assertions', () => { describe('when asserting on a type that is not a Nock', () => { it('throws a type error', () => { - expect( - () => expect('NOT_A_NOCK').to.have.been.requestedWith() - ).to.throw(TypeError); + expect(() => expect('NOT_A_NOCK').to.have.been.requestedWith()).to.throw( + TypeError, + ); - expect( - () => expect({}).to.have.been.requestedWith() - ).to.throw(TypeError); + expect(() => expect({}).to.have.been.requestedWith()).to.throw(TypeError); - expect( - () => expect(nock('http://url-without.a').get('/interceptor')).to.have.been.requestedWith() + expect(() => + expect( + nock('http://url-without.a').get('/interceptor'), + ).to.have.been.requestedWith(), ).to.throw(TypeError); }); }); @@ -32,28 +33,32 @@ describe('requestedWith() assertions', () => { describe('when a request to the nock has been made with the correct argument', () => { describe('with a simple argument', () => { it('passes', () => { - const requestNock = nock(TEST_URL).get('/').reply(200); + const requestNock = nock(TEST_URL) + .get('/') + .reply(200); request({ json: true, uri: TEST_URL, - body: 'test' + body: 'test', }); - + return expect(requestNock).to.have.been.requestedWith('test'); }); }); describe('with an Object as an argument', () => { it('passes', () => { - const requestNock = nock(TEST_URL).get('/').reply(200); + const requestNock = nock(TEST_URL) + .get('/') + .reply(200); request({ json: true, uri: TEST_URL, body: { test: 123, - } + }, }); - + return expect(requestNock).to.have.been.requestedWith({ test: 123, }); @@ -62,35 +67,47 @@ describe('requestedWith() assertions', () => { }); describe('when a request to the nock has been made but with incorrect arguments', () => { - it('throws', (done) => { - const requestNock = nock(TEST_URL).get('/').reply(200); + it('throws', done => { + const requestNock = nock(TEST_URL) + .get('/') + .reply(200); request({ json: true, uri: TEST_URL, - body: { test: 1 } + body: { test: 1 }, }); - const assertion = expect(requestNock).to.have.been.requestedWith({ test: 2 }); + const assertion = expect(requestNock).to.have.been.requestedWith({ + test: 2, + }); return assertion - .then(() => done.fail('Should have thrown an error')) - .catch((err) => { - expect(err.message).to.equal('expected Nock to have been requested with { test: 2 }, but was requested with { test: 1 }'); - done(); - }); + .then(() => done.fail('Should have thrown an error')) + .catch(err => { + expect(err.message).to.equal( + 'expected Nock to have been requested with { test: 2 }, but was requested with { test: 1 }', + ); + done(); + }); }); }); - + describe('when a request to the nock has not been made', () => { - it('throws', (done) => { - const requestNock = nock(TEST_URL).get('/').reply(200); + it('throws', done => { + const requestNock = nock(TEST_URL) + .get('/') + .reply(200); - const assertion = expect(requestNock).to.have.been.requestedWith({ test: 123 }); + const assertion = expect(requestNock).to.have.been.requestedWith({ + test: 123, + }); return assertion .then(() => done.fail('Should have thrown an error')) - .catch((err) => { - expect(err.message).to.equal('expected Nock to have been requested, but it was never called'); + .catch(err => { + expect(err.message).to.equal( + 'expected Nock to have been requested, but it was never called', + ); done(); }); }); @@ -100,43 +117,57 @@ describe('requestedWith() assertions', () => { describe('.not.requestedWith()', () => { describe('when a request to the nock has been made with the incorrect arguments', () => { it('passes', () => { - const requestNock = nock(TEST_URL).get('/').reply(200); + const requestNock = nock(TEST_URL) + .get('/') + .reply(200); request({ json: true, uri: TEST_URL, - body: { test: 123 } + body: { test: 123 }, }); - return expect(requestNock).not.to.have.been.requestedWith('different_value'); + return expect(requestNock).not.to.have.been.requestedWith( + 'different_value', + ); }); }); describe('when a request to the nock has not been made', () => { it('passes', () => { - const requestNock = nock(TEST_URL).get('/').reply(200); + const requestNock = nock(TEST_URL) + .get('/') + .reply(200); - return expect(requestNock).not.to.have.been.requestedWith('different_value'); + return expect(requestNock).not.to.have.been.requestedWith( + 'different_value', + ); }); }); describe('when a request to the nock has been made with matching arguments', () => { - it('throws', (done) => { + it('throws', done => { const mockArgument = { test: 12345, }; - const requestNock = nock(TEST_URL).get('/').reply(200); + const requestNock = nock(TEST_URL) + .get('/') + .reply(200); request({ json: true, uri: TEST_URL, - body: mockArgument + body: mockArgument, }); - const assertion = expect(requestNock).not.to.have.been.requestedWith(mockArgument); + const assertion = expect(requestNock).not.to.have.been.requestedWith( + mockArgument, + ); return assertion .then(() => done.fail('Should have thrown an error')) - .catch((err) => { - expect(err.message).to.equal('expected Nock to have not been requested with { test: 12345 }'); + .catch(err => { + expect(err.message).to.equal( + 'expected Nock to have not been requested with { test: 12345 }', + ); done(); }); });