@sinonjs/samsam
Advanced tools
Comparing version 5.3.1 to 6.0.0
# Changes | ||
## 6.0.0 | ||
- [`95d1dce`](https://github.com/sinonjs/samsam/commit/95d1dce07f47b7bbb84111c42f44ecd9466dc2c8) | ||
Use @sinonjs/eslint-config (Morgan Roderick) | ||
> | ||
> This drops support for legacy runtimes like IE11, legacy Edge, Safari 9 and the like | ||
_Released on 2021-03-30._ | ||
## 5.3.1 | ||
@@ -4,0 +13,0 @@ |
@@ -15,3 +15,2 @@ # samsam | ||
### `isArguments(value)` | ||
@@ -21,3 +20,2 @@ | ||
### `isNegZero(value)` | ||
@@ -27,3 +25,2 @@ | ||
### `isElement(value)` | ||
@@ -33,3 +30,3 @@ | ||
Underscore.js/lodash, this function will return `false` if `value` is an | ||
*element-like* object, i.e. a regular object with a `nodeType` property that | ||
_element-like_ object, i.e. a regular object with a `nodeType` property that | ||
holds the value `1`. | ||
@@ -41,6 +38,4 @@ | ||
## Comparison functions | ||
### `identical(x, y)` | ||
@@ -53,4 +48,4 @@ | ||
> An egal function simply makes available the internal `SameValue` function | ||
from section 9.12 of the ES5 spec. If two values are egal, then they are not | ||
observably distinguishable. | ||
> from section 9.12 of the ES5 spec. If two values are egal, then they are not | ||
> observably distinguishable. | ||
@@ -61,3 +56,2 @@ `identical` returns `true` when `===` is `true`, except for `-0` and | ||
### `deepEqual(actual, expectation)` | ||
@@ -67,11 +61,10 @@ | ||
* They are identical | ||
* They are both date objects representing the same time | ||
* They are both arrays containing elements that are all deepEqual | ||
* They are objects with the same set of properties, and each property | ||
in `actual` is deepEqual to the corresponding property in `expectation` | ||
- They are identical | ||
- They are both date objects representing the same time | ||
- They are both arrays containing elements that are all deepEqual | ||
- They are objects with the same set of properties, and each property | ||
in `actual` is deepEqual to the corresponding property in `expectation` | ||
* `actual` can have [symbolic properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) that are missing from `expectation` | ||
- `actual` can have [symbolic properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) that are missing from `expectation` | ||
### Matcher | ||
@@ -86,3 +79,2 @@ | ||
#### `sinon.match.defined` | ||
@@ -92,3 +84,2 @@ | ||
#### `sinon.match.truthy` | ||
@@ -98,3 +89,2 @@ | ||
#### `sinon.match.falsy` | ||
@@ -104,3 +94,2 @@ | ||
#### `sinon.match.bool` | ||
@@ -110,3 +99,2 @@ | ||
#### `sinon.match.number` | ||
@@ -116,3 +104,2 @@ | ||
#### `sinon.match.string` | ||
@@ -122,3 +109,2 @@ | ||
#### `sinon.match.object` | ||
@@ -128,3 +114,2 @@ | ||
#### `sinon.match.func` | ||
@@ -134,3 +119,2 @@ | ||
#### `sinon.match.array` | ||
@@ -140,3 +124,2 @@ | ||
#### `sinon.match.array.deepEquals(arr)` | ||
@@ -146,3 +129,2 @@ | ||
#### `sinon.match.array.startsWith(arr)` | ||
@@ -152,3 +134,2 @@ | ||
#### `sinon.match.array.endsWith(arr)` | ||
@@ -158,3 +139,2 @@ | ||
#### `sinon.match.array.contains(arr)` | ||
@@ -164,3 +144,2 @@ | ||
#### `sinon.match.map` | ||
@@ -170,3 +149,2 @@ | ||
#### `sinon.match.map.deepEquals(map)` | ||
@@ -180,3 +158,2 @@ | ||
#### `sinon.match.set` | ||
@@ -186,3 +163,2 @@ | ||
#### `sinon.match.set.deepEquals(set)` | ||
@@ -192,3 +168,2 @@ | ||
#### `sinon.match.set.contains(set)` | ||
@@ -198,3 +173,2 @@ | ||
#### `sinon.match.regexp` | ||
@@ -204,3 +178,2 @@ | ||
#### `sinon.match.date` | ||
@@ -210,3 +183,2 @@ | ||
#### `sinon.match.symbol` | ||
@@ -227,15 +199,14 @@ | ||
Requires the value to be of the given type, where `type` can be one of | ||
`"undefined"`, | ||
`"null"`, | ||
`"boolean"`, | ||
`"number"`, | ||
`"string"`, | ||
`"object"`, | ||
`"function"`, | ||
`"array"`, | ||
`"regexp"`, | ||
`"date"` or | ||
`"symbol"`. | ||
`"undefined"`, | ||
`"null"`, | ||
`"boolean"`, | ||
`"number"`, | ||
`"string"`, | ||
`"object"`, | ||
`"function"`, | ||
`"array"`, | ||
`"regexp"`, | ||
`"date"` or | ||
`"symbol"`. | ||
#### `sinon.match.instanceOf(type)` | ||
@@ -255,3 +226,2 @@ | ||
#### `sinon.match.hasNested(propertyPath[, expectation])` | ||
@@ -263,3 +233,2 @@ | ||
```javascript | ||
@@ -269,3 +238,3 @@ sinon.match.hasNested("a[0].b.c"); | ||
// Where actual is something like | ||
var actual = { "a": [{ "b": { "c": 3 } }] }; | ||
var actual = { a: [{ b: { c: 3 } }] }; | ||
@@ -275,3 +244,3 @@ sinon.match.hasNested("a.b.c"); | ||
// Where actual is something like | ||
var actual = { "a": { "b": { "c": 3 } } }; | ||
var actual = { a: { b: { c: 3 } } }; | ||
``` | ||
@@ -311,3 +280,10 @@ | ||
samsam.match("Give me something", "sumptn"); // false | ||
samsam.match({ toString: function () { return "yeah"; } }, "Yeah!"); // true | ||
samsam.match( | ||
{ | ||
toString: function () { | ||
return "yeah"; | ||
}, | ||
}, | ||
"Yeah!" | ||
); // true | ||
``` | ||
@@ -320,3 +296,2 @@ | ||
#### Boolean matcher | ||
@@ -327,3 +302,2 @@ | ||
#### Regular expression matcher | ||
@@ -338,7 +312,13 @@ | ||
samsam.match("Give me something", /[0-9]/); // false | ||
samsam.match({ toString: function () { return "yeah!"; } }, /yeah/); // true | ||
samsam.match( | ||
{ | ||
toString: function () { | ||
return "yeah!"; | ||
}, | ||
}, | ||
/yeah/ | ||
); // true | ||
samsam.match(234, /[a-z]/); // false | ||
``` | ||
#### Number matcher | ||
@@ -351,7 +331,13 @@ | ||
samsam.match("Give me something", 425); // false | ||
samsam.match({ toString: function () { return "42"; } }, 42); // true | ||
samsam.match( | ||
{ | ||
toString: function () { | ||
return "42"; | ||
}, | ||
}, | ||
42 | ||
); // true | ||
samsam.match(234, 1234); // false | ||
``` | ||
#### Function matcher | ||
@@ -376,7 +362,12 @@ | ||
// true | ||
samsam.match({ | ||
toString: function () { | ||
return "42"; | ||
samsam.match( | ||
{ | ||
toString: function () { | ||
return "42"; | ||
}, | ||
}, | ||
function () { | ||
return true; | ||
} | ||
}, function () { return true; }); | ||
); | ||
@@ -387,3 +378,2 @@ // false | ||
#### Object matcher | ||
@@ -407,3 +397,3 @@ | ||
return arg == 123; | ||
} | ||
}, | ||
}); | ||
@@ -415,8 +405,11 @@ | ||
// true | ||
samsam.match({ | ||
name: "Chris", | ||
profession: "Programmer" | ||
}, { | ||
name: "Chris" | ||
}); | ||
samsam.match( | ||
{ | ||
name: "Chris", | ||
profession: "Programmer", | ||
}, | ||
{ | ||
name: "Chris", | ||
} | ||
); | ||
@@ -427,3 +420,2 @@ // false | ||
#### DOM elements | ||
@@ -440,4 +432,4 @@ | ||
className: "item", | ||
innerHTML: "Howdy" | ||
innerHTML: "Howdy", | ||
}); | ||
``` |
@@ -13,5 +13,5 @@ "use strict"; | ||
Float32Array, | ||
Float64Array | ||
Float64Array, | ||
]; | ||
module.exports = ARRAY_TYPES; |
@@ -47,3 +47,3 @@ "use strict"; | ||
throw new TypeError( | ||
"Expected 1 or 2 arguments, received " + arguments.length | ||
`Expected 1 or 2 arguments, received ${arguments.length}` | ||
); | ||
@@ -55,3 +55,3 @@ } | ||
} else { | ||
m.test = function(actual) { | ||
m.test = function (actual) { | ||
return deepEqual(actual, expectation); | ||
@@ -62,3 +62,3 @@ }; | ||
if (!m.message) { | ||
m.message = "match(" + valueToString(expectation) + ")"; | ||
m.message = `match(${valueToString(expectation)})`; | ||
} | ||
@@ -71,25 +71,25 @@ | ||
createMatcher.any = createMatcher(function() { | ||
createMatcher.any = createMatcher(function () { | ||
return true; | ||
}, "any"); | ||
createMatcher.defined = createMatcher(function(actual) { | ||
createMatcher.defined = createMatcher(function (actual) { | ||
return actual !== null && actual !== undefined; | ||
}, "defined"); | ||
createMatcher.truthy = createMatcher(function(actual) { | ||
createMatcher.truthy = createMatcher(function (actual) { | ||
return Boolean(actual); | ||
}, "truthy"); | ||
createMatcher.falsy = createMatcher(function(actual) { | ||
createMatcher.falsy = createMatcher(function (actual) { | ||
return !actual; | ||
}, "falsy"); | ||
createMatcher.same = function(expectation) { | ||
return createMatcher(function(actual) { | ||
createMatcher.same = function (expectation) { | ||
return createMatcher(function (actual) { | ||
return expectation === actual; | ||
}, "same(" + valueToString(expectation) + ")"); | ||
}, `same(${valueToString(expectation)})`); | ||
}; | ||
createMatcher.in = function(arrayOfExpectations) { | ||
createMatcher.in = function (arrayOfExpectations) { | ||
if (typeOf(arrayOfExpectations) !== "array") { | ||
@@ -99,17 +99,17 @@ throw new TypeError("array expected"); | ||
return createMatcher(function(actual) { | ||
return some(arrayOfExpectations, function(expectation) { | ||
return createMatcher(function (actual) { | ||
return some(arrayOfExpectations, function (expectation) { | ||
return expectation === actual; | ||
}); | ||
}, "in(" + valueToString(arrayOfExpectations) + ")"); | ||
}, `in(${valueToString(arrayOfExpectations)})`); | ||
}; | ||
createMatcher.typeOf = function(type) { | ||
createMatcher.typeOf = function (type) { | ||
assertType(type, "string", "type"); | ||
return createMatcher(function(actual) { | ||
return createMatcher(function (actual) { | ||
return typeOf(actual) === type; | ||
}, 'typeOf("' + type + '")'); | ||
}, `typeOf("${type}")`); | ||
}; | ||
createMatcher.instanceOf = function(type) { | ||
createMatcher.instanceOf = function (type) { | ||
/* istanbul ignore if */ | ||
@@ -129,5 +129,5 @@ if ( | ||
} | ||
return createMatcher(function(actual) { | ||
return createMatcher(function (actual) { | ||
return actual instanceof type; | ||
}, "instanceOf(" + (functionName(type) || objectToString(type)) + ")"); | ||
}, `instanceOf(${functionName(type) || objectToString(type)})`); | ||
}; | ||
@@ -144,11 +144,11 @@ | ||
function createPropertyMatcher(propertyTest, messagePrefix) { | ||
return function(property, value) { | ||
return function (property, value) { | ||
assertType(property, "string", "property"); | ||
var onlyProperty = arguments.length === 1; | ||
var message = messagePrefix + '("' + property + '"'; | ||
var message = `${messagePrefix}("${property}"`; | ||
if (!onlyProperty) { | ||
message += ", " + valueToString(value); | ||
message += `, ${valueToString(value)}`; | ||
} | ||
message += ")"; | ||
return createMatcher(function(actual) { | ||
return createMatcher(function (actual) { | ||
if ( | ||
@@ -166,3 +166,3 @@ actual === undefined || | ||
createMatcher.has = createPropertyMatcher(function(actual, property) { | ||
createMatcher.has = createPropertyMatcher(function (actual, property) { | ||
if (typeof actual === "object") { | ||
@@ -174,15 +174,15 @@ return property in actual; | ||
createMatcher.hasOwn = createPropertyMatcher(function(actual, property) { | ||
createMatcher.hasOwn = createPropertyMatcher(function (actual, property) { | ||
return hasOwnProperty(actual, property); | ||
}, "hasOwn"); | ||
createMatcher.hasNested = function(property, value) { | ||
createMatcher.hasNested = function (property, value) { | ||
assertType(property, "string", "property"); | ||
var onlyProperty = arguments.length === 1; | ||
var message = 'hasNested("' + property + '"'; | ||
var message = `hasNested("${property}"`; | ||
if (!onlyProperty) { | ||
message += ", " + valueToString(value); | ||
message += `, ${valueToString(value)}`; | ||
} | ||
message += ")"; | ||
return createMatcher(function(actual) { | ||
return createMatcher(function (actual) { | ||
if ( | ||
@@ -205,10 +205,10 @@ actual === undefined || | ||
object: true, | ||
array: true | ||
array: true, | ||
}; | ||
createMatcher.json = function(value) { | ||
createMatcher.json = function (value) { | ||
if (!jsonParseResultTypes[typeOf(value)]) { | ||
throw new TypeError("Value cannot be the result of JSON.parse"); | ||
} | ||
var message = "json(" + JSON.stringify(value, null, " ") + ")"; | ||
return createMatcher(function(actual) { | ||
var message = `json(${JSON.stringify(value, null, " ")})`; | ||
return createMatcher(function (actual) { | ||
var parsed; | ||
@@ -224,8 +224,8 @@ try { | ||
createMatcher.every = function(predicate) { | ||
createMatcher.every = function (predicate) { | ||
assertMatcher(predicate); | ||
return createMatcher(function(actual) { | ||
return createMatcher(function (actual) { | ||
if (typeOf(actual) === "object") { | ||
return every(Object.keys(actual), function(key) { | ||
return every(Object.keys(actual), function (key) { | ||
return predicate.test(actual[key]); | ||
@@ -237,15 +237,15 @@ }); | ||
isIterable(actual) && | ||
every(actual, function(element) { | ||
every(actual, function (element) { | ||
return predicate.test(element); | ||
}) | ||
); | ||
}, "every(" + predicate.message + ")"); | ||
}, `every(${predicate.message})`); | ||
}; | ||
createMatcher.some = function(predicate) { | ||
createMatcher.some = function (predicate) { | ||
assertMatcher(predicate); | ||
return createMatcher(function(actual) { | ||
return createMatcher(function (actual) { | ||
if (typeOf(actual) === "object") { | ||
return !every(Object.keys(actual), function(key) { | ||
return !every(Object.keys(actual), function (key) { | ||
return !predicate.test(actual[key]); | ||
@@ -257,7 +257,7 @@ }); | ||
isIterable(actual) && | ||
!every(actual, function(element) { | ||
!every(actual, function (element) { | ||
return !predicate.test(element); | ||
}) | ||
); | ||
}, "some(" + predicate.message + ")"); | ||
}, `some(${predicate.message})`); | ||
}; | ||
@@ -267,4 +267,4 @@ | ||
createMatcher.array.deepEquals = function(expectation) { | ||
return createMatcher(function(actual) { | ||
createMatcher.array.deepEquals = function (expectation) { | ||
return createMatcher(function (actual) { | ||
// Comparing lengths is the fastest way to spot a difference before iterating through every item | ||
@@ -275,3 +275,3 @@ var sameLength = actual.length === expectation.length; | ||
sameLength && | ||
every(actual, function(element, index) { | ||
every(actual, function (element, index) { | ||
var expected = expectation[index]; | ||
@@ -284,18 +284,18 @@ return typeOf(expected) === "array" && | ||
); | ||
}, "deepEquals([" + iterableToString(expectation) + "])"); | ||
}, `deepEquals([${iterableToString(expectation)}])`); | ||
}; | ||
createMatcher.array.startsWith = function(expectation) { | ||
return createMatcher(function(actual) { | ||
createMatcher.array.startsWith = function (expectation) { | ||
return createMatcher(function (actual) { | ||
return ( | ||
typeOf(actual) === "array" && | ||
every(expectation, function(expectedElement, index) { | ||
every(expectation, function (expectedElement, index) { | ||
return actual[index] === expectedElement; | ||
}) | ||
); | ||
}, "startsWith([" + iterableToString(expectation) + "])"); | ||
}, `startsWith([${iterableToString(expectation)}])`); | ||
}; | ||
createMatcher.array.endsWith = function(expectation) { | ||
return createMatcher(function(actual) { | ||
createMatcher.array.endsWith = function (expectation) { | ||
return createMatcher(function (actual) { | ||
// This indicates the index in which we should start matching | ||
@@ -306,18 +306,18 @@ var offset = actual.length - expectation.length; | ||
typeOf(actual) === "array" && | ||
every(expectation, function(expectedElement, index) { | ||
every(expectation, function (expectedElement, index) { | ||
return actual[offset + index] === expectedElement; | ||
}) | ||
); | ||
}, "endsWith([" + iterableToString(expectation) + "])"); | ||
}, `endsWith([${iterableToString(expectation)}])`); | ||
}; | ||
createMatcher.array.contains = function(expectation) { | ||
return createMatcher(function(actual) { | ||
createMatcher.array.contains = function (expectation) { | ||
return createMatcher(function (actual) { | ||
return ( | ||
typeOf(actual) === "array" && | ||
every(expectation, function(expectedElement) { | ||
every(expectation, function (expectedElement) { | ||
return arrayIndexOf(actual, expectedElement) !== -1; | ||
}) | ||
); | ||
}, "contains([" + iterableToString(expectation) + "])"); | ||
}, `contains([${iterableToString(expectation)}])`); | ||
}; | ||
@@ -328,3 +328,3 @@ | ||
createMatcher.map.deepEquals = function mapDeepEquals(expectation) { | ||
return createMatcher(function(actual) { | ||
return createMatcher(function (actual) { | ||
// Comparing lengths is the fastest way to spot a difference before iterating through every item | ||
@@ -335,18 +335,18 @@ var sameLength = actual.size === expectation.size; | ||
sameLength && | ||
every(actual, function(element, key) { | ||
every(actual, function (element, key) { | ||
return expectation.has(key) && expectation.get(key) === element; | ||
}) | ||
); | ||
}, "deepEquals(Map[" + iterableToString(expectation) + "])"); | ||
}, `deepEquals(Map[${iterableToString(expectation)}])`); | ||
}; | ||
createMatcher.map.contains = function mapContains(expectation) { | ||
return createMatcher(function(actual) { | ||
return createMatcher(function (actual) { | ||
return ( | ||
typeOf(actual) === "map" && | ||
every(expectation, function(element, key) { | ||
every(expectation, function (element, key) { | ||
return actual.has(key) && actual.get(key) === element; | ||
}) | ||
); | ||
}, "contains(Map[" + iterableToString(expectation) + "])"); | ||
}, `contains(Map[${iterableToString(expectation)}])`); | ||
}; | ||
@@ -357,3 +357,3 @@ | ||
createMatcher.set.deepEquals = function setDeepEquals(expectation) { | ||
return createMatcher(function(actual) { | ||
return createMatcher(function (actual) { | ||
// Comparing lengths is the fastest way to spot a difference before iterating through every item | ||
@@ -364,18 +364,18 @@ var sameLength = actual.size === expectation.size; | ||
sameLength && | ||
every(actual, function(element) { | ||
every(actual, function (element) { | ||
return expectation.has(element); | ||
}) | ||
); | ||
}, "deepEquals(Set[" + iterableToString(expectation) + "])"); | ||
}, `deepEquals(Set[${iterableToString(expectation)}])`); | ||
}; | ||
createMatcher.set.contains = function setContains(expectation) { | ||
return createMatcher(function(actual) { | ||
return createMatcher(function (actual) { | ||
return ( | ||
typeOf(actual) === "set" && | ||
every(expectation, function(element) { | ||
every(expectation, function (element) { | ||
return actual.has(element); | ||
}) | ||
); | ||
}, "contains(Set[" + iterableToString(expectation) + "])"); | ||
}, `contains(Set[${iterableToString(expectation)}])`); | ||
}; | ||
@@ -382,0 +382,0 @@ |
@@ -15,5 +15,3 @@ "use strict"; | ||
if (value[method] === null || value[method] === undefined) { | ||
throw new TypeError( | ||
"Expected " + name + " to have method " + methodPath | ||
); | ||
throw new TypeError(`Expected ${name} to have method ${methodPath}`); | ||
} | ||
@@ -20,0 +18,0 @@ } |
@@ -19,8 +19,3 @@ "use strict"; | ||
throw new TypeError( | ||
"Expected type of " + | ||
name + | ||
" to be " + | ||
type + | ||
", but was " + | ||
actual | ||
`Expected type of ${name} to be ${type}, but was ${actual}` | ||
); | ||
@@ -27,0 +22,0 @@ } |
@@ -35,3 +35,3 @@ "use strict"; | ||
return every(expectedKeys, function(key) { | ||
return every(expectedKeys, function (key) { | ||
var exp = expectation[key]; | ||
@@ -38,0 +38,0 @@ var act = actual[key]; |
"use strict"; | ||
var matcherPrototype = { | ||
toString: function() { | ||
toString: function () { | ||
return this.message; | ||
} | ||
}, | ||
}; | ||
matcherPrototype.or = function(valueOrMatcher) { | ||
matcherPrototype.or = function (valueOrMatcher) { | ||
var createMatcher = require("../create-matcher"); | ||
@@ -22,10 +22,10 @@ var isMatcher = createMatcher.isMatcher; | ||
var or = Object.create(matcherPrototype); | ||
or.test = function(actual) { | ||
or.test = function (actual) { | ||
return m1.test(actual) || m2.test(actual); | ||
}; | ||
or.message = m1.message + ".or(" + m2.message + ")"; | ||
or.message = `${m1.message}.or(${m2.message})`; | ||
return or; | ||
}; | ||
matcherPrototype.and = function(valueOrMatcher) { | ||
matcherPrototype.and = function (valueOrMatcher) { | ||
var createMatcher = require("../create-matcher"); | ||
@@ -43,6 +43,6 @@ var isMatcher = createMatcher.isMatcher; | ||
var and = Object.create(matcherPrototype); | ||
and.test = function(actual) { | ||
and.test = function (actual) { | ||
return m1.test(actual) && m2.test(actual); | ||
}; | ||
and.message = m1.message + ".and(" + m2.message + ")"; | ||
and.message = `${m1.message}.and(${m2.message})`; | ||
return and; | ||
@@ -49,0 +49,0 @@ }; |
@@ -11,10 +11,10 @@ "use strict"; | ||
var createTypeMap = function(match) { | ||
var createTypeMap = function (match) { | ||
return { | ||
function: function(m, expectation, message) { | ||
function: function (m, expectation, message) { | ||
m.test = expectation; | ||
m.message = message || "match(" + functionName(expectation) + ")"; | ||
m.message = message || `match(${functionName(expectation)})`; | ||
}, | ||
number: function(m, expectation) { | ||
m.test = function(actual) { | ||
number: function (m, expectation) { | ||
m.test = function (actual) { | ||
// we need type coercion here | ||
@@ -24,31 +24,31 @@ return expectation == actual; // eslint-disable-line eqeqeq | ||
}, | ||
object: function(m, expectation) { | ||
object: function (m, expectation) { | ||
var array = []; | ||
if (typeof expectation.test === "function") { | ||
m.test = function(actual) { | ||
m.test = function (actual) { | ||
return expectation.test(actual) === true; | ||
}; | ||
m.message = "match(" + functionName(expectation.test) + ")"; | ||
m.message = `match(${functionName(expectation.test)})`; | ||
return m; | ||
} | ||
array = map(Object.keys(expectation), function(key) { | ||
return key + ": " + valueToString(expectation[key]); | ||
array = map(Object.keys(expectation), function (key) { | ||
return `${key}: ${valueToString(expectation[key])}`; | ||
}); | ||
m.test = function(actual) { | ||
m.test = function (actual) { | ||
return matchObject(actual, expectation, match); | ||
}; | ||
m.message = "match(" + join(array, ", ") + ")"; | ||
m.message = `match(${join(array, ", ")})`; | ||
return m; | ||
}, | ||
regexp: function(m, expectation) { | ||
m.test = function(actual) { | ||
regexp: function (m, expectation) { | ||
m.test = function (actual) { | ||
return typeof actual === "string" && expectation.test(actual); | ||
}; | ||
}, | ||
string: function(m, expectation) { | ||
m.test = function(actual) { | ||
string: function (m, expectation) { | ||
m.test = function (actual) { | ||
return ( | ||
@@ -59,4 +59,4 @@ typeof actual === "string" && | ||
}; | ||
m.message = 'match("' + expectation + '")'; | ||
} | ||
m.message = `match("${expectation}")`; | ||
}, | ||
}; | ||
@@ -63,0 +63,0 @@ }; |
@@ -27,3 +27,3 @@ "use strict"; | ||
forEach(items, function(item) { | ||
forEach(items, function (item) { | ||
set.add(item); | ||
@@ -30,0 +30,0 @@ }); |
@@ -42,9 +42,9 @@ "use strict"; | ||
new Set(), | ||
// eslint-disable-next-line no-undef, ie11/no-weak-collections | ||
// eslint-disable-next-line no-undef | ||
new WeakMap(), | ||
// eslint-disable-next-line no-undef, ie11/no-weak-collections | ||
new WeakSet() | ||
] | ||
} | ||
} | ||
// eslint-disable-next-line no-undef | ||
new WeakSet(), | ||
], | ||
}, | ||
}, | ||
}; | ||
@@ -55,3 +55,3 @@ var complex2 = Object.create(complex1); | ||
"4a092cd1-225e-4739-8331-d6564aafb702": | ||
"d0cebbe0-23fb-4cc4-8fa0-ef11ceedf12e" | ||
"d0cebbe0-23fb-4cc4-8fa0-ef11ceedf12e", | ||
}; | ||
@@ -64,10 +64,10 @@ cyclic1.cyclicRef = cyclic1; | ||
suite | ||
.add("complex objects", function() { | ||
.add("complex objects", function () { | ||
return deepEqual(complex1, complex2); | ||
}) | ||
.add("cyclic references", function() { | ||
.add("cyclic references", function () { | ||
return deepEqual(cyclic1, cyclic2); | ||
}) | ||
// add listeners | ||
.on("cycle", function(event) { | ||
.on("cycle", function (event) { | ||
// eslint-disable-next-line no-console | ||
@@ -74,0 +74,0 @@ console.log(String(event.target)); |
@@ -179,3 +179,3 @@ "use strict"; | ||
var mapsDeeplyEqual = true; | ||
mapForEach(actualObj, function(value, key) { | ||
mapForEach(actualObj, function (value, key) { | ||
mapsDeeplyEqual = | ||
@@ -189,3 +189,3 @@ mapsDeeplyEqual && | ||
return every(expectationKeysAndSymbols, function(key) { | ||
return every(expectationKeysAndSymbols, function (key) { | ||
if (!hasOwnProperty(actualObj, key)) { | ||
@@ -215,7 +215,7 @@ return false; | ||
? actualPaths[actualIndex] | ||
: actualPath + "[" + JSON.stringify(key) + "]"; | ||
: `${actualPath}[${JSON.stringify(key)}]`; | ||
var newExpectationPath = | ||
expectationIndex !== -1 | ||
? expectationPaths[expectationIndex] | ||
: expectationPath + "[" + JSON.stringify(key) + "]"; | ||
: `${expectationPath}[${JSON.stringify(key)}]`; | ||
var combinedPath = newActualPath + newExpectationPath; | ||
@@ -257,3 +257,3 @@ | ||
deepEqualCyclic.use = function(match) { | ||
deepEqualCyclic.use = function (match) { | ||
return function deepEqual(a, b) { | ||
@@ -260,0 +260,0 @@ return deepEqualCyclic(a, b, match); |
@@ -17,5 +17,5 @@ "use strict"; | ||
var allContained = true; | ||
forEach(s1, function(v1) { | ||
forEach(s1, function (v1) { | ||
var includes = false; | ||
forEach(s2, function(v2) { | ||
forEach(s2, function (v2) { | ||
if (compare(v2, v1)) { | ||
@@ -22,0 +22,0 @@ includes = true; |
@@ -33,4 +33,4 @@ "use strict"; | ||
// eslint-disable-next-line @sinonjs/no-prototype-methods/no-prototype-methods | ||
map.forEach(function(value, key) { | ||
representation += "[" + stringify(key) + "," + stringify(value) + "],"; | ||
map.forEach(function (value, key) { | ||
representation += `[${stringify(key)},${stringify(value)}],`; | ||
}); | ||
@@ -53,4 +53,4 @@ | ||
// eslint-disable-next-line @sinonjs/no-prototype-methods/no-prototype-methods | ||
iterable.forEach(function(value) { | ||
representation += stringify(value) + ","; | ||
iterable.forEach(function (value) { | ||
representation += `${stringify(value)},`; | ||
}); | ||
@@ -70,5 +70,5 @@ | ||
function stringify(item) { | ||
return typeof item === "string" ? "'" + item + "'" : valueToString(item); | ||
return typeof item === "string" ? `'${item}'` : valueToString(item); | ||
} | ||
module.exports = iterableToString; |
@@ -170,3 +170,3 @@ "use strict"; | ||
forEach(Object.keys(createMatcher), function(key) { | ||
forEach(Object.keys(createMatcher), function (key) { | ||
match[key] = createMatcher[key]; | ||
@@ -173,0 +173,0 @@ }); |
@@ -25,3 +25,3 @@ "use strict"; | ||
isSet: isSet, | ||
match: match | ||
match: match, | ||
}; |
{ | ||
"name": "@sinonjs/samsam", | ||
"version": "5.3.1", | ||
"version": "6.0.0", | ||
"description": "Value identification and comparison functions", | ||
@@ -15,2 +15,3 @@ "homepage": "http://sinonjs.github.io/samsam/", | ||
"lint-staged": { | ||
"*.{js,css,md}": "prettier --check", | ||
"*.js": "eslint" | ||
@@ -29,2 +30,4 @@ }, | ||
"test-headless": "mochify --no-detect-globals --recursive -R dot --plugin [ proxyquire-universal ] \"./lib/*.test.js\"", | ||
"prettier:check": "prettier --check '**/*.{js,css,md}'", | ||
"prettier:write": "prettier --write '**/*.{js,css,md}'", | ||
"preversion": "npm run test-check-coverage", | ||
@@ -50,2 +53,3 @@ "version": "changes --commits --footer", | ||
"devDependencies": { | ||
"@sinonjs/eslint-config": "^4.0.0", | ||
"@sinonjs/eslint-plugin-no-prototype-methods": "^0.1.0", | ||
@@ -55,9 +59,2 @@ "@sinonjs/referee": "^5.0.0", | ||
"benchmark": "2.1.4", | ||
"eslint": "^6.2.0", | ||
"eslint-config-prettier": "^6.1.0", | ||
"eslint-config-sinon": "^4.0.0", | ||
"eslint-plugin-ie11": "^1.0.0", | ||
"eslint-plugin-jsdoc": "^22.1.0", | ||
"eslint-plugin-mocha": "^6.0.0", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"husky": "^4.2.1", | ||
@@ -74,3 +71,3 @@ "jquery": "^3.4.1", | ||
"nyc": "^15.0.0", | ||
"prettier": "^1.18.2", | ||
"prettier": "^2.2.1", | ||
"proxyquire": "^2.1.3", | ||
@@ -92,3 +89,8 @@ "proxyquire-universal": "^2.1.0", | ||
] | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
} | ||
} |
@@ -46,3 +46,2 @@ # samsam | ||
## Sponsors | ||
@@ -49,0 +48,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92390
21
1665
84