response-objects
Advanced tools
Comparing version 0.3.3 to 0.4.0
@@ -62,5 +62,5 @@ const status = require("statuses"); | ||
resp.status = resp.statusCode = code; | ||
if (body != null) resp.body = body; | ||
resp.body = body != null ? body : status[code]; | ||
if (headers != null) resp.headers = headers; | ||
return resp; | ||
} |
{ | ||
"name": "response-objects", | ||
"version": "0.3.3", | ||
"version": "0.4.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
11
test.js
@@ -60,2 +60,11 @@ const expect = require("expect"); | ||
it("defaults to status text on null/undefined body", function () { | ||
expect(Ctor().body).toBe(status[statusCode]); | ||
expect(Ctor(null).body).toBe(status[statusCode]); | ||
// other falsy values are ok | ||
expect(Ctor(0).body).toBe(0); | ||
expect(Ctor("").body).toBe(""); | ||
}); | ||
it("throws if body argument is already a response", function () { | ||
@@ -90,3 +99,3 @@ expect(() => Ctor(someResponse)).toThrow(/Object is already a response/); | ||
// 4.8s with `new` constructors + failed `this instanceof` checks | ||
describe("create 1e7 instances", function () { | ||
xdescribe("create 1e7 instances", function () { | ||
it("is fast enough", function () { | ||
@@ -93,0 +102,0 @@ const body = {}, headers = {}; |
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
20364
136