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

unexpected

Package Overview
Dependencies
Maintainers
2
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 1.0.13 to 1.1.0

21

lib/unexpected.js

@@ -566,3 +566,3 @@ // Copyright (c) 2013 Sune Simonsen <sune@we-knowhow.dk>

expect.addAssertion('[not] to (throw|throw error|throw exception)', function (fn) {
expect.addAssertion('[not] to (throw|throw error|throw exception)', function (arg) {
if (typeof this.obj !== 'function') {

@@ -575,2 +575,3 @@ throw new Error("Assertion '" + this.testDescription +

var not = this.flags.not;
var argType = typeof arg;

@@ -581,15 +582,15 @@ try {

var subject = 'string' === typeof e ? e : e.message;
if ('function' === typeof fn) {
fn(e);
} else if ('object' === typeof fn) {
if ('function' === argType) {
arg(e);
} else if ('string' === argType) {
if (not) {
expect(subject, 'not to match', fn);
expect(subject, 'not to be', arg);
} else {
expect(subject, 'to match', fn);
expect(subject, 'to be', arg);
}
} else if ('string' === typeof fn) {
} else if (isRegExp(arg)) {
if (not) {
expect(subject, 'not to be', fn);
expect(subject, 'not to match', arg);
} else {
expect(subject, 'to be', fn);
expect(subject, 'to match', arg);
}

@@ -600,3 +601,3 @@ }

if ('function' !== typeof fn && not) {
if (('string' === argType || isRegExp(arg)) && not) {
// in the presence of a matcher, ensure the `not` only applies to

@@ -603,0 +604,0 @@ // the matching.

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

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

@@ -249,3 +249,16 @@ /*global describe, it, expect*/

}, 'to throw', 'expected [Function] to throw exception');
});
it('fails if expection is throw', function () {
expect(function () {
expect(function () {
throw new Error('The exception message');
}, 'not to throw exception');
}, 'to throw');
expect(function () {
expect(function () {
throw new Error('The exception message');
}, 'not to throw exception');
}, 'to throw', 'expected [Function] not to throw exception');
});

@@ -252,0 +265,0 @@ it('fails if the argument is not a function', function () {

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