Skip to content

Commit

Permalink
Update prettier and reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
mantoni committed Jan 24, 2023
1 parent aa3978a commit cd5caf5
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 35 deletions.
4 changes: 2 additions & 2 deletions lib/assertions/exception.js
Original file line number Diff line number Diff line change
@@ -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");

Expand Down
4 changes: 2 additions & 2 deletions lib/assertions/less.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions lib/assertions/same.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
41 changes: 20 additions & 21 deletions lib/define-assertion/interpolate-properties.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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;
17 changes: 10 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit cd5caf5

Please sign in to comment.