diff --git a/lib/assertions/exception.js b/lib/assertions/exception.js index 14ef80c..c984951 100644 --- a/lib/assertions/exception.js +++ b/lib/assertions/exception.js @@ -1,8 +1,8 @@ "use strict"; var samsam = require("@sinonjs/samsam"); -var hasOwnProperty = require("@sinonjs/commons").prototypes.object - .hasOwnProperty; +var hasOwnProperty = + require("@sinonjs/commons").prototypes.object.hasOwnProperty; var captureException = require("../capture-exception"); diff --git a/lib/assertions/less.test.js b/lib/assertions/less.test.js index 1438b3b..233601d 100644 --- a/lib/assertions/less.test.js +++ b/lib/assertions/less.test.js @@ -10,8 +10,8 @@ describe("less factory", function () { "bbedde65-07b1-451a-9ba1-afe28b07786d"; this.factory = proxyquire("./less", { - "../actual-and-expected-message-values": this - .fakeActualAndExpectedMessageValues, + "../actual-and-expected-message-values": + this.fakeActualAndExpectedMessageValues, }); this.fakeReferee = { diff --git a/lib/assertions/same.test.js b/lib/assertions/same.test.js index 2335996..c530beb 100644 --- a/lib/assertions/same.test.js +++ b/lib/assertions/same.test.js @@ -13,8 +13,8 @@ describe("same factory", function () { "866c5b01-0028-4cf2-8dd7-9ef99bbc53b0"; var factory = proxyquire("./same", { - "../actual-and-expected-message-values": this - .fakeActualAndExpectedMessageValues, + "../actual-and-expected-message-values": + this.fakeActualAndExpectedMessageValues, }); this.fakeReferee = { diff --git a/lib/define-assertion/interpolate-properties.js b/lib/define-assertion/interpolate-properties.js index 13f375a..01efdbe 100644 --- a/lib/define-assertion/interpolate-properties.js +++ b/lib/define-assertion/interpolate-properties.js @@ -1,7 +1,7 @@ "use strict"; -var hasOwnProperty = require("@sinonjs/commons").prototypes.object - .hasOwnProperty; +var hasOwnProperty = + require("@sinonjs/commons").prototypes.object.hasOwnProperty; var format = require("./format"); function prepareMessage(message) { @@ -12,26 +12,25 @@ function prepareMessage(message) { } function interpolateProperties(referee, message, properties) { - return message.replace(/\${(\.\.\.|!)?([a-z]+)}/gi, function ( - match, - prefix, - name - ) { - if (!hasOwnProperty(properties, name)) { - return match; + return message.replace( + /\${(\.\.\.|!)?([a-z]+)}/gi, + function (match, prefix, name) { + if (!hasOwnProperty(properties, name)) { + return match; + } + var value = properties[name]; + if (prefix === "!") { + return value; + } + if (prefix === "..." && Array.isArray(value)) { + return value.map(format).join(", "); + } + if (name === "customMessage") { + return prepareMessage(value); + } + return format(value); } - var value = properties[name]; - if (prefix === "!") { - return value; - } - if (prefix === "..." && Array.isArray(value)) { - return value.map(format).join(", "); - } - if (name === "customMessage") { - return prepareMessage(value); - } - return format(value); - }); + ); } module.exports = interpolateProperties; diff --git a/package-lock.json b/package-lock.json index a32966a..980b419 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,7 @@ "mkdirp": "^1.0.3", "mocha": "^10.2.0", "nyc": "^15.1.0", - "prettier": "^2.1.2", + "prettier": "^2.8.3", "proxyquire": "^2.1.3", "sinon": "^15.0.1" } @@ -3646,15 +3646,18 @@ } }, "node_modules/prettier": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.2.tgz", - "integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.3.tgz", + "integrity": "sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==", "dev": true, "bin": { "prettier": "bin-prettier.js" }, "engines": { "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" } }, "node_modules/process-on-spawn": { @@ -7317,9 +7320,9 @@ "dev": true }, "prettier": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.2.tgz", - "integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.3.tgz", + "integrity": "sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==", "dev": true }, "process-on-spawn": { diff --git a/package.json b/package.json index 0e6bb1e..91578e9 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "mkdirp": "^1.0.3", "mocha": "^10.2.0", "nyc": "^15.1.0", - "prettier": "^2.1.2", + "prettier": "^2.8.3", "proxyquire": "^2.1.3", "sinon": "^15.0.1" }