New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dmail/expect

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dmail/expect - npm Package Compare versions

Comparing version 2.5.1 to 2.6.0

17

dist/src/expectMatch/expectProperties/expectProperties.js

@@ -31,3 +31,14 @@ "use strict";

return (0, _action.any)([(0, _expectType.expectObject)(actual), (0, _expectType.expectFunction)(actual)]).then(function () {
var listNames = Object.getOwnPropertyNames;
var listNames = function listNames(value) {
var names = Object.getOwnPropertyNames(value);
if (typeof value === "function") {
return names.filter(function (name) {
return name !== "length" && name !== "name" && name !== "arguments" && name !== "caller" && name !== "prototype";
});
}
return names;
};
var actualPropertyNames = listNames(actual);

@@ -131,4 +142,6 @@ var expectedPropertyNames = listNames(expected);

return (0, _expectMatch.matchExactly)(value);
}
} // beware it can recurse indefinitely if the object structure is circular
// like function with .prototype.constructor cycling back on the function
return matchPropertiesDeep(value);

@@ -135,0 +148,0 @@ }

101

dist/src/expectMatch/expectProperties/expectProperties.test.js

@@ -7,3 +7,3 @@ "use strict";

var _expectProperties = require("./expectProperties.js");
var _expectProperties2 = require("./expectProperties.js");

@@ -33,5 +33,10 @@ var _test = require("@dmail/test");

exports.default = (0, _test.createTest)({
"expectProperties(null)": function expectPropertiesNull(_ref) {
"expectProperties(() => {})": function expectProperties(_ref) {
var pass = _ref.pass;
assertFailedWith((0, _expectProperties.expectProperties)(null, {
assertPassedWith((0, _expectProperties2.expectProperties)(function () {}, function () {}), []);
pass();
},
"expectProperties(null)": function expectPropertiesNull(_ref2) {
var pass = _ref2.pass;
assertFailedWith((0, _expectProperties2.expectProperties)(null, {
foo: true

@@ -41,5 +46,5 @@ }), "expect a function or an object to compare properties but got null");

},
"expectProperties(undefined)": function expectPropertiesUndefined(_ref2) {
var pass = _ref2.pass;
assertFailedWith((0, _expectProperties.expectProperties)(undefined, {
"expectProperties(undefined)": function expectPropertiesUndefined(_ref3) {
var pass = _ref3.pass;
assertFailedWith((0, _expectProperties2.expectProperties)(undefined, {
foo: true

@@ -49,5 +54,5 @@ }), "expect a function or an object to compare properties but got undefined");

},
"expectProperties(true)": function expectPropertiesTrue(_ref3) {
var pass = _ref3.pass;
assertFailedWith((0, _expectProperties.expectProperties)(true, {
"expectProperties(true)": function expectPropertiesTrue(_ref4) {
var pass = _ref4.pass;
assertFailedWith((0, _expectProperties2.expectProperties)(true, {
foo: true

@@ -57,4 +62,4 @@ }), "expect a function or an object to compare properties but got a boolean: true");

},
"expectProperties with extra non enumerable property": function expectPropertiesWithExtraNonEnumerableProperty(_ref4) {
var pass = _ref4.pass;
"expectProperties with extra non enumerable property": function expectPropertiesWithExtraNonEnumerableProperty(_ref5) {
var pass = _ref5.pass;
var actual = {};

@@ -65,8 +70,8 @@ Object.defineProperty(actual, "name", {

});
assertPassedWith((0, _expectProperties.expectProperties)(actual, {}), []);
assertPassedWith((0, _expectProperties2.expectProperties)(actual, {}), []);
pass();
},
"expectProperties({}, {foo: true})": function expectPropertiesFooTrue(_ref5) {
var pass = _ref5.pass;
assertFailedWith((0, _expectProperties.expectProperties)({}, {
"expectProperties({}, {foo: true})": function expectPropertiesFooTrue(_ref6) {
var pass = _ref6.pass;
assertFailedWith((0, _expectProperties2.expectProperties)({}, {
foo: true

@@ -76,5 +81,5 @@ }), "missing foo property");

},
"expectProperties({foo: true}, {foo: true})": function expectPropertiesFooTrueFooTrue(_ref6) {
var pass = _ref6.pass;
assertPassedWith((0, _expectProperties.expectProperties)({
"expectProperties({foo: true}, {foo: true})": function expectPropertiesFooTrueFooTrue(_ref7) {
var pass = _ref7.pass;
assertPassedWith((0, _expectProperties2.expectProperties)({
foo: true

@@ -86,5 +91,5 @@ }, {

},
"expectProperties({foo: true}, {})": function expectPropertiesFooTrue(_ref7) {
var pass = _ref7.pass;
assertFailedWith((0, _expectProperties.expectProperties)({
"expectProperties({foo: true}, {})": function expectPropertiesFooTrue(_ref8) {
var pass = _ref8.pass;
assertFailedWith((0, _expectProperties2.expectProperties)({
foo: true

@@ -94,5 +99,5 @@ }, {}), "unexpected foo property");

},
"expectProperties({foo: 10}, {foo: matchBelow(5)}": function expectPropertiesFoo10FooMatchBelow5(_ref8) {
var pass = _ref8.pass;
assertFailedWith((0, _expectProperties.expectProperties)({
"expectProperties({foo: 10}, {foo: matchBelow(5)}": function expectPropertiesFoo10FooMatchBelow5(_ref9) {
var pass = _ref9.pass;
assertFailedWith((0, _expectProperties2.expectProperties)({
foo: 10

@@ -104,5 +109,5 @@ }, {

},
"expectPropertiesAllowingExtra({foo: 10}, {})": function expectPropertiesAllowingExtraFoo10(_ref9) {
var pass = _ref9.pass;
assertPassedWith((0, _expectProperties.expectPropertiesAllowingExtra)({
"expectPropertiesAllowingExtra({foo: 10}, {})": function expectPropertiesAllowingExtraFoo10(_ref10) {
var pass = _ref10.pass;
assertPassedWith((0, _expectProperties2.expectPropertiesAllowingExtra)({
foo: 10

@@ -112,5 +117,5 @@ }, {}), []);

},
"expectPropertiesAllowingExtra({foo: 10, bar: true}, {foo: 10})": function expectPropertiesAllowingExtraFoo10BarTrueFoo10(_ref10) {
var pass = _ref10.pass;
assertPassedWith((0, _expectProperties.expectPropertiesAllowingExtra)({
"expectPropertiesAllowingExtra({foo: 10, bar: true}, {foo: 10})": function expectPropertiesAllowingExtraFoo10BarTrueFoo10(_ref11) {
var pass = _ref11.pass;
assertPassedWith((0, _expectProperties2.expectPropertiesAllowingExtra)({
foo: 10,

@@ -123,5 +128,5 @@ bar: true

},
"expectPropertyNames({foo: true}, 'foo')": function expectPropertyNamesFooTrueFoo(_ref11) {
var pass = _ref11.pass;
assertPassedWith((0, _expectProperties.expectPropertyNames)({
"expectPropertyNames({foo: true}, 'foo')": function expectPropertyNamesFooTrueFoo(_ref12) {
var pass = _ref12.pass;
assertPassedWith((0, _expectProperties2.expectPropertyNames)({
foo: true

@@ -131,5 +136,5 @@ }, "foo"), [undefined]);

},
"expectPropertyNamesAllowingExtra({foo: true})": function expectPropertyNamesAllowingExtraFooTrue(_ref12) {
var pass = _ref12.pass;
assertPassedWith((0, _expectProperties.expectPropertyNamesAllowingExtra)({
"expectPropertyNamesAllowingExtra({foo: true})": function expectPropertyNamesAllowingExtraFooTrue(_ref13) {
var pass = _ref13.pass;
assertPassedWith((0, _expectProperties2.expectPropertyNamesAllowingExtra)({
foo: true

@@ -139,5 +144,5 @@ }), []);

},
"expectPropertyNamesAllowingExtra({foo: true, bar: true}, 'foo')": function expectPropertyNamesAllowingExtraFooTrueBarTrueFoo(_ref13) {
var pass = _ref13.pass;
assertPassedWith((0, _expectProperties.expectPropertyNamesAllowingExtra)({
"expectPropertyNamesAllowingExtra({foo: true, bar: true}, 'foo')": function expectPropertyNamesAllowingExtraFooTrueBarTrueFoo(_ref14) {
var pass = _ref14.pass;
assertPassedWith((0, _expectProperties2.expectPropertyNamesAllowingExtra)({
foo: true,

@@ -148,4 +153,4 @@ bar: true

},
"expectPropertiesIncludingHidden()": function expectPropertiesIncludingHidden(_ref14) {
var pass = _ref14.pass;
"expectPropertiesIncludingHidden()": function expectPropertiesIncludingHidden(_ref15) {
var pass = _ref15.pass;
var actual = {};

@@ -156,8 +161,8 @@ Object.defineProperty(actual, "name", {

});
assertFailedWith((0, _expectProperties.expectPropertiesIncludingHidden)(actual, {}), "unexpected name property");
assertFailedWith((0, _expectProperties2.expectPropertiesIncludingHidden)(actual, {}), "unexpected name property");
pass();
},
"expectPropertiesDeep() with similar objects": function expectPropertiesDeepWithSimilarObjects(_ref15) {
var pass = _ref15.pass;
assertPassedWith((0, _expectProperties.expectPropertiesDeep)({
"expectPropertiesDeep() with similar objects": function expectPropertiesDeepWithSimilarObjects(_ref16) {
var pass = _ref16.pass;
assertPassedWith((0, _expectProperties2.expectPropertiesDeep)({
user: {

@@ -173,5 +178,5 @@ name: "dam"

},
"expectPropertiesDeep() with unexpected deep value": function expectPropertiesDeepWithUnexpectedDeepValue(_ref16) {
var pass = _ref16.pass;
assertFailedWith((0, _expectProperties.expectPropertiesDeep)({
"expectPropertiesDeep() with unexpected deep value": function expectPropertiesDeepWithUnexpectedDeepValue(_ref17) {
var pass = _ref17.pass;
assertFailedWith((0, _expectProperties2.expectPropertiesDeep)({
user: {

@@ -178,0 +183,0 @@ name: "dam"

{
"name": "@dmail/expect",
"version": "2.5.1",
"version": "2.6.0",
"license": "MIT",

@@ -22,3 +22,3 @@ "repository": {

"dependencies": {
"@dmail/action": "1.6.0",
"@dmail/action": "1.7.0",
"@dmail/spy": "0.0.2",

@@ -25,0 +25,0 @@ "@dmail/uneval": "1.0.0"

@@ -23,3 +23,16 @@ import { failed, all, any } from "@dmail/action"

() => {
const listNames = Object.getOwnPropertyNames
const listNames = value => {
const names = Object.getOwnPropertyNames(value)
if (typeof value === "function") {
return names.filter(
name =>
name !== "length" &&
name !== "name" &&
name !== "arguments" &&
name !== "caller" &&
name !== "prototype"
)
}
return names
}

@@ -108,2 +121,4 @@ const actualPropertyNames = listNames(actual)

}
// beware it can recurse indefinitely if the object structure is circular
// like function with .prototype.constructor cycling back on the function
return matchPropertiesDeep(value)

@@ -110,0 +125,0 @@ }

@@ -24,2 +24,6 @@ import {

export default createTest({
"expectProperties(() => {})": ({ pass }) => {
assertPassedWith(expectProperties(() => {}, () => {}), [])
pass()
},
"expectProperties(null)": ({ pass }) => {

@@ -26,0 +30,0 @@ assertFailedWith(

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc