Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unexpected

Package Overview
Dependencies
Maintainers
3
Versions
330
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unexpected - npm Package Compare versions

Comparing version 10.13.2 to 10.13.3

lib/addAdditionalPromiseMethods.js

5

lib/createWrappedExpectProto.js

@@ -7,3 +7,3 @@ var createStandardErrorMessage = require('./createStandardErrorMessage');

var notifyPendingPromise = require('./notifyPendingPromise');
var makeAndMethod = require('./makeAndMethod');
var addAdditionalPromiseMethods = require('./addAdditionalPromiseMethods');
var utils = require('./utils');

@@ -88,4 +88,3 @@

}
result.and = makeAndMethod(that.execute, that.subject);
return result;
return addAdditionalPromiseMethods(result, that.execute, that.subject);
} catch (e) {

@@ -92,0 +91,0 @@ if (e && e._isUnexpected) {

8

lib/makePromise.js

@@ -114,6 +114,10 @@ var Promise = require('unexpected-bluebird');

['resolve', 'reject'].forEach(function (staticMethodName) {
makePromise[staticMethodName] = Promise[staticMethodName];
// Expose all of Bluebird's static methods, except the ones related to long stack traces,
// unhandled rejections and the scheduler, which we need to manage ourselves:
Object.keys(Promise).forEach(function (staticMethodName) {
if (!/^_|^on|^setScheduler|ongStackTraces/.test(staticMethodName) && typeof Promise[staticMethodName] === 'function' && typeof makePromise[staticMethodName] === 'undefined') {
makePromise[staticMethodName] = Promise[staticMethodName];
}
});
module.exports = makePromise;

@@ -7,3 +7,3 @@ var createStandardErrorMessage = require('./createStandardErrorMessage');

var makePromise = require('./makePromise');
var makeAndMethod = require('./makeAndMethod');
var addAdditionalPromiseMethods = require('./addAdditionalPromiseMethods');
var isPendingPromise = require('./isPendingPromise');

@@ -711,11 +711,33 @@ var oathbreaker = require('./oathbreaker');

function getPluginName(plugin) {
if (typeof plugin === 'function') {
return utils.getFunctionName(plugin);
} else {
return plugin.name;
}
}
Unexpected.prototype.use = function (plugin) {
if ((typeof plugin !== 'function' && (typeof plugin !== 'object' || typeof plugin.installInto !== 'function')) ||
(typeof plugin.name !== 'undefined' && typeof plugin.name !== 'string') ||
(typeof plugin.dependencies !== 'undefined' && !Array.isArray(plugin.dependencies))) {
throw new Error(
'Plugins must be functions or adhere to the following interface\n' +
'{\n' +
' name: <an optional plugin name>,\n' +
' version: <an optional semver version string>,\n' +
' dependencies: <an optional list of dependencies>,\n' +
' installInto: <a function that will update the given expect instance>\n' +
'}'
);
}
var pluginName = getPluginName(plugin);
var existingPlugin = utils.findFirst(this.installedPlugins, function (installedPlugin) {
if (installedPlugin === plugin) {
return true;
} else if (typeof plugin === 'function' && typeof installedPlugin === 'function') {
var pluginName = utils.getFunctionName(plugin);
return pluginName !== '' && pluginName === utils.getFunctionName(installedPlugin);
} else {
return installedPlugin.name === plugin.name;
return pluginName && pluginName === getPluginName(installedPlugin);
}

@@ -729,3 +751,3 @@ });

} else {
throw new Error("Another instance of the plugin '" + plugin.name + "' " +
throw new Error("Another instance of the plugin '" + pluginName + "' " +
"is already installed" +

@@ -741,15 +763,3 @@ (typeof existingPlugin.version !== 'undefined' ?

if ((typeof plugin !== 'function' && (typeof plugin !== 'object' || typeof plugin.installInto !== 'function')) ||
(typeof plugin.name !== 'undefined' && typeof plugin.name !== 'string') ||
(typeof plugin.dependencies !== 'undefined' && !Array.isArray(plugin.dependencies))) {
throw new Error('Plugins must be functions or adhere to the following interface\n' +
'{\n' +
' name: <an optional plugin name>,\n' +
' version: <an optional semver version string>,\n' +
' dependencies: <an optional list of dependencies>,\n' +
' installInto: <a function that will update the given expect instance>\n' +
'}');
}
if (plugin.name === 'unexpected-promise') {
if (pluginName === 'unexpected-promise') {
throw new Error('The unexpected-promise plugin was pulled into Unexpected as of 8.5.0. This means that the plugin is no longer supported.');

@@ -762,3 +772,3 @@ }

return !installedPlugins.some(function (plugin) {
return plugin.name === dependency;
return getPluginName(plugin) === dependency;
});

@@ -768,5 +778,5 @@ });

if (unfulfilledDependencies.length === 1) {
throw new Error(plugin.name + ' requires plugin ' + unfulfilledDependencies[0]);
throw new Error(pluginName + ' requires plugin ' + unfulfilledDependencies[0]);
} else if (unfulfilledDependencies.length > 1) {
throw new Error(plugin.name + ' requires plugins ' +
throw new Error(pluginName + ' requires plugins ' +
unfulfilledDependencies.slice(0, -1).join(', ') +

@@ -931,3 +941,3 @@ ' and ' + unfulfilledDependencies[unfulfilledDependencies.length - 1]);

if (typeof testDescriptionString !== 'string') {
throw new Error('The expect function requires the second parameter to be a string.');
throw new Error('The expect function requires the second parameter to be a string or an expect.it.');
}

@@ -1023,2 +1033,8 @@ var handlers = this.assertions[testDescriptionString];

throw new Error('The expect function requires at least two parameters.');
} else if (testDescriptionString && testDescriptionString._expectIt) {
return that.expect.withError(function () {
return testDescriptionString(subject);
}, function (err) {
that.fail(err);
});
}

@@ -1053,5 +1069,16 @@

var flags = extend({}, assertionRule.flags);
var wrappedExpect = function () {
var subject = arguments[0];
var testDescriptionString = arguments[1].replace(/\[(!?)([^\]]+)\] ?/g, function (match, negate, flag) {
var wrappedExpect = function (subject, testDescriptionString) {
if (arguments.length === 0) {
throw new Error('The expect function requires at least one parameter.');
} else if (arguments.length === 1) {
return addAdditionalPromiseMethods(makePromise.resolve(subject), wrappedExpect, subject);
} else if (testDescriptionString && testDescriptionString._expectIt) {
wrappedExpect.errorMode = 'nested';
return wrappedExpect.withError(function () {
return testDescriptionString(subject);
}, function (err) {
wrappedExpect.fail(err);
});
}
testDescriptionString = testDescriptionString.replace(/\[(!?)([^\]]+)\] ?/g, function (match, negate, flag) {
return Boolean(flags[flag]) !== Boolean(negate) ? flag + ' ' : '';

@@ -1124,4 +1151,3 @@ }).trim();

}
result.and = makeAndMethod(that.expect, subject);
return result;
return addAdditionalPromiseMethods(result, that.expect, subject);
} catch (e) {

@@ -1128,0 +1154,0 @@ if (e && e._isUnexpected) {

@@ -226,3 +226,3 @@ var utils = require('./utils');

if (!this.useFullStackTrace) {
if (this.stack && !this.useFullStackTrace) {
var newStack = [];

@@ -229,0 +229,0 @@ var removedFrames = false;

{
"name": "unexpected",
"version": "10.13.2",
"version": "10.13.3",
"author": "Sune Sloth Simonsen <sune@we-knowhow.dk>",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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