@shopify/jest-koa-mocks
Advanced tools
Comparing version 5.1.1 to 5.2.0
@@ -34,3 +34,4 @@ 'use strict'; | ||
} = options; | ||
const extensions = { ...customProperties, | ||
const extensions = { | ||
...customProperties, | ||
throw: throwFn, | ||
@@ -51,5 +52,6 @@ session, | ||
} | ||
}); // Some functions we call in the implementations will perform checks for `req.encrypted`, which delegates to the socket. | ||
}); | ||
// Some functions we call in the implementations will perform checks for `req.encrypted`, which delegates to the socket. | ||
// MockRequest doesn't set a fake socket itself, so we create one here. | ||
req.socket = new stream__default["default"].Duplex(); | ||
@@ -60,6 +62,9 @@ Object.defineProperty(req.socket, 'encrypted', { | ||
}); | ||
const res = httpMocks__default["default"].createResponse(); // Koa sets a default status code of 404, not the node default of 200 | ||
const res = httpMocks__default["default"].createResponse(); | ||
// Koa sets a default status code of 404, not the node default of 200 | ||
// https://github.com/koajs/koa/blob/master/docs/api/response.md#responsestatus | ||
res.statusCode = 404; | ||
res.statusCode = 404; // This is to get around an odd behavior in the `cookies` library, where if `res.set` is defined, it will use an internal | ||
// This is to get around an odd behavior in the `cookies` library, where if `res.set` is defined, it will use an internal | ||
// node function to set headers, which results in them being set in the wrong place. | ||
@@ -70,4 +75,5 @@ | ||
Object.assign(context, extensions); | ||
context.cookies = createMockCookies["default"](cookies); // ctx.request.body is a common enough custom property for middleware to add that it's handy to just support it by default | ||
context.cookies = createMockCookies["default"](cookies); | ||
// ctx.request.body is a common enough custom property for middleware to add that it's handy to just support it by default | ||
context.request.body = requestBody; | ||
@@ -74,0 +80,0 @@ context.request.rawBody = rawBody; |
{ | ||
"name": "@shopify/jest-koa-mocks", | ||
"version": "5.1.1", | ||
"version": "5.2.0", | ||
"license": "MIT", | ||
@@ -23,3 +23,3 @@ "description": "Utilities to easily stub Koa context and cookies", | ||
"engines": { | ||
"node": "^14.17.0 || >=16.0.0" | ||
"node": ">=18.12.0" | ||
}, | ||
@@ -26,0 +26,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
21391
240