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

unexpected-messy

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unexpected-messy - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

60

lib/unexpectedMessy.js

@@ -316,3 +316,4 @@ var messy = require('messy'),

} catch (e) {
output.sp().error('// should satisfy ').text(expectedHeaderValue);
// https://github.com/sunesimonsen/unexpected/issues/76
output.sp().error('// should ' + (typeof expectedHeaderValue === 'string' ? 'be ' : 'satisfy ')).text(expectedHeaderValue);
}

@@ -739,12 +740,51 @@ remainingExpectedHeaders.remove(headerName, 0);

}).addAssertion('messy.HttpExchange', 'to [exhaustively] satisfy', function (expect, subject, value) {
if ('request' in value) {
expect(subject.request, 'to [exhaustively] satisfy', value.request);
} else {
expect(this.flags.exhaustively, 'to be false');
try {
if ('request' in value) {
expect(subject.request, 'to [exhaustively] satisfy', value.request);
} else {
expect(this.flags.exhaustively, 'to be false');
}
if ('response' in value) {
expect(subject.response, 'to [exhaustively] satisfy', value.response);
} else {
expect(this.flags.exhaustively, 'to be false');
}
} catch (e) {
if (e._isUnexpected) {
var flags = this.flags;
e.createDiff = function (output, diff, inspect, equal) {
if ('request' in value) {
try {
expect(subject.request, 'to [exhaustively] satisfy', value.request);
output.append(expect.inspect(subject.request));
} catch (e) {
output.append(e.createDiff(output.clone(), diff, inspect, equal).diff);
}
} else {
if (flags.exhaustively) {
output.error('// Request not matched exhaustively');
}
}
if (flags.exhaustively || ('request' in value && 'response' in value)) {
output.nl(2);
}
if ('response' in value) {
try {
expect(subject.response, 'to [exhaustively] satisfy', value.response);
output.append(expect.inspect(subject.response));
} catch (e) {
output.append(e.createDiff(output.clone(), diff, inspect, equal).diff);
}
} else {
if (flags.exhaustively) {
output.error('// Response not matched exhaustively');
}
}
return {
diff: output
};
};
}
expect.fail(e);
}
if ('response' in value) {
expect(subject.response, 'to [exhaustively] satisfy', value.response);
} else {
expect(this.flags.exhaustively, 'to be false');
}
}).addType({

@@ -751,0 +791,0 @@ name: 'messy.HttpConversation',

2

package.json
{
"name": "unexpected-messy",
"version": "1.1.0",
"version": "1.2.0",
"description": "Unexpected plugin for the messy library",

@@ -5,0 +5,0 @@ "main": "lib/unexpectedMessy.js",

@@ -569,3 +569,3 @@ /*global describe, it*/

'GET / HTTP/1.1 // should be POST\n' +
'Content-Type: text/html // should satisfy application/json\n' +
'Content-Type: text/html // should be application/json\n' +
'\n' +

@@ -596,3 +596,3 @@ '-argh\n' +

'GET / HTTP/1.1\n' +
'Content-Type: text/html // should satisfy application/json\n' +
'Content-Type: text/html // should be application/json\n' +
'\n' +

@@ -648,3 +648,3 @@ '-argh\n' +

'GET / HTTP/1.1 // should be POST\n' +
'Content-Type: text/html // should satisfy application/json\n' +
'Content-Type: text/html // should be application/json\n' +
'\n' +

@@ -850,3 +850,3 @@ 'argh'

'HTTP/1.1 200 OK // should be 412 Precondition Failed\n' +
'Content-Type: text/html // should satisfy application/json\n' +
'Content-Type: text/html // should be application/json\n' +
'\n' +

@@ -877,3 +877,3 @@ '-argh\n' +

'HTTP/1.1 200 OK\n' +
'Content-Type: text/html // should satisfy application/json\n' +
'Content-Type: text/html // should be application/json\n' +
'\n' +

@@ -904,3 +904,3 @@ '-argh\n' +

'HTTP/1.1 200 OK\n' +
'Content-Type: text/html // should satisfy application/json\n' +
'Content-Type: text/html // should be application/json\n' +
'\n' +

@@ -930,3 +930,3 @@ '-argh\n' +

'HTTP/1.1 200 OK // should be 412 Precondition Failed\n' +
'Content-Type: text/html // should satisfy application/json\n' +
'Content-Type: text/html // should be application/json\n' +
'\n' +

@@ -1016,2 +1016,105 @@ 'argh'

});
describe('"to satisfy" assertion', function () {
it('should produce a diff when the assertion fails', function () {
expect(function () {
expect(new HttpExchange({
request: 'GET / HTTP/1.1\r\nContent-Type: application/json\r\n\r\n{"foo":"bar"}',
response: 'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\nargh',
}), 'to satisfy', {request: {url: '/foo'}, response: {body: 'blah'}});
}, 'to throw',
'expected\n' +
'GET / HTTP/1.1\n' +
'Content-Type: application/json\n' +
'\n' +
"{ foo: 'bar' }\n" +
'\n' +
'HTTP/1.1 200 OK\n' +
'Content-Type: text/html\n' +
'\n' +
'argh\n' +
"to satisfy { request: { url: '/foo' }, response: { body: 'blah' } }\n" +
'\n' +
'Diff:\n' +
'\n' +
'GET / HTTP/1.1 // should be /foo\n' +
'Content-Type: application/json\n' +
'\n' +
"{ foo: 'bar' }\n" +
'\n' +
'HTTP/1.1 200 OK\n' +
'Content-Type: text/html\n' +
'\n' +
'-argh\n' +
'+blah'
);
});
it('should produce a diff when there is no diff in the request', function () {
expect(function () {
expect(new HttpExchange({
request: 'GET / HTTP/1.1\r\nContent-Type: application/json\r\n\r\n{"foo":"bar"}',
response: 'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\nargh',
}), 'to satisfy', {request: {url: '/'}, response: {body: 'blah'}});
}, 'to throw',
'expected\n' +
'GET / HTTP/1.1\n' +
'Content-Type: application/json\n' +
'\n' +
"{ foo: 'bar' }\n" +
'\n' +
'HTTP/1.1 200 OK\n' +
'Content-Type: text/html\n' +
'\n' +
'argh\n' +
"to satisfy { request: { url: '/' }, response: { body: 'blah' } }\n" +
'\n' +
'Diff:\n' +
'\n' +
'GET / HTTP/1.1\n' +
'Content-Type: application/json\n' +
'\n' +
"{ foo: 'bar' }\n" +
'\n' +
'HTTP/1.1 200 OK\n' +
'Content-Type: text/html\n' +
'\n' +
'-argh\n' +
'+blah'
);
});
it('should produce a diff when there is no diff in the response', function () {
expect(function () {
expect(new HttpExchange({
request: 'GET / HTTP/1.1\r\nContent-Type: application/json\r\n\r\n{"foo":"bar"}',
response: 'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\nargh',
}), 'to satisfy', {request: {url: '/foo'}, response: {body: 'argh'}});
}, 'to throw',
'expected\n' +
'GET / HTTP/1.1\n' +
'Content-Type: application/json\n' +
'\n' +
"{ foo: 'bar' }\n" +
'\n' +
'HTTP/1.1 200 OK\n' +
'Content-Type: text/html\n' +
'\n' +
'argh\n' +
"to satisfy { request: { url: '/foo' }, response: { body: 'argh' } }\n" +
'\n' +
'Diff:\n' +
'\n' +
'GET / HTTP/1.1 // should be /foo\n' +
'Content-Type: application/json\n' +
'\n' +
"{ foo: 'bar' }\n" +
'\n' +
'HTTP/1.1 200 OK\n' +
'Content-Type: text/html\n' +
'\n' +
'argh'
);
});
});
});

@@ -1018,0 +1121,0 @@

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