@cedarjs/testing 0.1.1-next.0 → 0.1.2-next.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/jest/api/jest.setup.js +1 -1
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-commented-exports/code.js +28 -0
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-commented-exports/output.js +35 -0
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-and-other-named-export/code.js +7 -0
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-and-other-named-export/output.js +6 -0
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-export/code.js +3 -0
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-export/output.js +3 -0
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-required-exports/code.js +28 -0
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-required-exports/output.js +34 -0
- package/config/jest/babelPlugins/__tests__/__fixtures__/viteDistDir/client-build-manifest.json +59 -0
- package/config/jest/babelPlugins/__tests__/babel-plugin-redwood-cell.test.ts +11 -0
- package/config/jest/babelPlugins/babel-plugin-redwood-cell.js +142 -0
- package/config/jest/package.json +3 -0
- package/config/jest/web/jest-preset.js +2 -2
- package/config/jest/web/jest.setup.js +2 -2
- package/config/jest/web/webBabelConfig.js +16 -1
- package/dist/api/apiFunction.js +4 -30
- package/dist/api/directUrlHelpers.js +4 -39
- package/dist/api/directive.js +13 -38
- package/dist/api/index.d.ts +3 -3
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +3 -26
- package/dist/api/scenario.js +2 -26
- package/dist/cache/index.js +2 -26
- package/dist/cjs/api/apiFunction.d.ts +37 -0
- package/dist/cjs/api/apiFunction.d.ts.map +1 -0
- package/dist/cjs/api/apiFunction.js +89 -0
- package/dist/cjs/api/directUrlHelpers.d.ts +3 -0
- package/dist/cjs/api/directUrlHelpers.d.ts.map +1 -0
- package/dist/cjs/api/directUrlHelpers.js +60 -0
- package/dist/cjs/api/directive.d.ts +51 -0
- package/dist/cjs/api/directive.d.ts.map +1 -0
- package/dist/cjs/api/directive.js +77 -0
- package/dist/cjs/api/index.d.ts +4 -0
- package/dist/cjs/api/index.d.ts.map +1 -0
- package/dist/cjs/api/index.js +26 -0
- package/dist/cjs/api/scenario.d.ts +108 -0
- package/dist/cjs/api/scenario.d.ts.map +1 -0
- package/dist/cjs/api/scenario.js +30 -0
- package/dist/cjs/cache/index.d.ts +50 -0
- package/dist/cjs/cache/index.d.ts.map +1 -0
- package/dist/cjs/cache/index.js +104 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/web/MockParamsProvider.d.ts +7 -0
- package/dist/cjs/web/MockParamsProvider.d.ts.map +1 -0
- package/dist/cjs/web/MockParamsProvider.js +44 -0
- package/dist/cjs/web/MockProviders.d.ts +9 -0
- package/dist/cjs/web/MockProviders.d.ts.map +1 -0
- package/dist/cjs/web/MockProviders.js +53 -0
- package/dist/cjs/web/MockRouter.d.ts +14 -0
- package/dist/cjs/web/MockRouter.d.ts.map +1 -0
- package/dist/cjs/web/MockRouter.js +48 -0
- package/dist/cjs/web/customRender.d.ts +6 -0
- package/dist/cjs/web/customRender.d.ts.map +1 -0
- package/dist/cjs/web/customRender.js +54 -0
- package/dist/cjs/web/fileMock.d.ts +9 -0
- package/dist/cjs/web/fileMock.d.ts.map +1 -0
- package/dist/cjs/web/fileMock.js +24 -0
- package/dist/cjs/web/findCellMocks.d.ts +2 -0
- package/dist/cjs/web/findCellMocks.d.ts.map +1 -0
- package/dist/cjs/web/findCellMocks.js +45 -0
- package/dist/cjs/web/global.d.ts +6 -0
- package/dist/cjs/web/global.d.ts.map +1 -0
- package/dist/cjs/web/global.js +1 -0
- package/dist/cjs/web/index.d.ts +6 -0
- package/dist/cjs/web/index.d.ts.map +1 -0
- package/dist/cjs/web/index.js +41 -0
- package/dist/cjs/web/mockAuth.d.ts +29 -0
- package/dist/cjs/web/mockAuth.d.ts.map +1 -0
- package/dist/cjs/web/mockAuth.js +89 -0
- package/dist/cjs/web/mockRequests.d.ts +30 -0
- package/dist/cjs/web/mockRequests.d.ts.map +1 -0
- package/dist/cjs/web/mockRequests.js +139 -0
- package/dist/web/MockParamsProvider.js +7 -41
- package/dist/web/MockProviders.d.ts.map +1 -1
- package/dist/web/MockProviders.js +10 -44
- package/dist/web/MockRouter.js +10 -37
- package/dist/web/customRender.js +9 -44
- package/dist/web/fileMock.js +3 -23
- package/dist/web/findCellMocks.js +4 -38
- package/dist/web/global.d.ts +1 -1
- package/dist/web/global.d.ts.map +1 -1
- package/dist/web/global.js +0 -1
- package/dist/web/index.d.ts +4 -5
- package/dist/web/index.d.ts.map +1 -1
- package/dist/web/index.js +13 -41
- package/dist/web/mockAuth.js +12 -49
- package/dist/web/mockRequests.js +6 -37
- package/package.json +79 -15
- package/api/index.js +0 -2
- package/api/package.json +0 -4
- package/cache/index.js +0 -2
- package/cache/package.json +0 -4
- package/web/index.js +0 -2
- package/web/package.json +0 -4
package/dist/api/index.js
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var api_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(api_exports);
|
|
18
|
-
__reExport(api_exports, require("./apiFunction"), module.exports);
|
|
19
|
-
__reExport(api_exports, require("./scenario"), module.exports);
|
|
20
|
-
__reExport(api_exports, require("./directive"), module.exports);
|
|
21
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
-
0 && (module.exports = {
|
|
23
|
-
...require("./apiFunction"),
|
|
24
|
-
...require("./scenario"),
|
|
25
|
-
...require("./directive")
|
|
26
|
-
});
|
|
1
|
+
export * from "./apiFunction.js";
|
|
2
|
+
export * from "./scenario.js";
|
|
3
|
+
export * from "./directive.js";
|
package/dist/api/scenario.js
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var scenario_exports = {};
|
|
20
|
-
__export(scenario_exports, {
|
|
21
|
-
defineScenario: () => defineScenario
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(scenario_exports);
|
|
24
1
|
const defineScenario = (data) => {
|
|
25
2
|
return data;
|
|
26
3
|
};
|
|
27
|
-
|
|
28
|
-
0 && (module.exports = {
|
|
4
|
+
export {
|
|
29
5
|
defineScenario
|
|
30
|
-
}
|
|
6
|
+
};
|
package/dist/cache/index.js
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var cache_exports = {};
|
|
20
|
-
__export(cache_exports, {
|
|
21
|
-
partialMatch: () => partialMatch
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(cache_exports);
|
|
24
1
|
expect.extend({
|
|
25
2
|
toHaveCached(cacheClient, keyOrExpectedValue, expectedValue) {
|
|
26
3
|
let value;
|
|
@@ -98,7 +75,6 @@ const _checkValueForKey = (cacheClient, cacheKey, expectedValue) => {
|
|
|
98
75
|
const partialMatch = (value) => {
|
|
99
76
|
return Array.isArray(value) ? expect.arrayContaining(value.map((v) => expect.objectContaining(v))) : expect.objectContaining(value);
|
|
100
77
|
};
|
|
101
|
-
|
|
102
|
-
0 && (module.exports = {
|
|
78
|
+
export {
|
|
103
79
|
partialMatch
|
|
104
|
-
}
|
|
80
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { APIGatewayProxyEvent, APIGatewayProxyEventHeaders, Context } from 'aws-lambda';
|
|
2
|
+
import type { SupportedVerifierTypes } from '@cedarjs/api/webhooks';
|
|
3
|
+
interface BuildEventParams extends Partial<APIGatewayProxyEvent> {
|
|
4
|
+
payload?: string | null | Record<any, any>;
|
|
5
|
+
signature?: string;
|
|
6
|
+
signatureHeader?: string;
|
|
7
|
+
headers?: APIGatewayProxyEventHeaders;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @description Use this to mock out the http request event that is received by your function in unit tests
|
|
11
|
+
*
|
|
12
|
+
* @example Mocking sending headers
|
|
13
|
+
* mockHttpEvent({header: {'X-Custom-Header': 'bazinga'}})
|
|
14
|
+
*
|
|
15
|
+
* @example Adding a JSON payload
|
|
16
|
+
* mockHttpEvent({payload: JSON.stringify(mockedRequestBody)})
|
|
17
|
+
*
|
|
18
|
+
* @returns APIGatewayProxyEvent
|
|
19
|
+
*/
|
|
20
|
+
export declare const mockHttpEvent: ({ payload, signature, signatureHeader, queryStringParameters, httpMethod, headers, path, isBase64Encoded, ...others }: BuildEventParams) => APIGatewayProxyEvent;
|
|
21
|
+
/**
|
|
22
|
+
* @description Use this function to mock the http event's context
|
|
23
|
+
* @see: https://docs.aws.amazon.com/lambda/latest/dg/nodejs-context.html
|
|
24
|
+
**/
|
|
25
|
+
export declare const mockContext: () => Context;
|
|
26
|
+
interface MockedSignedWebhookParams extends Omit<BuildEventParams, 'signature' | 'signatureHeader'> {
|
|
27
|
+
signatureType: Exclude<SupportedVerifierTypes, 'skipVerifier'>;
|
|
28
|
+
signatureHeader: string;
|
|
29
|
+
secret: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* @description Use this function to mock a signed webhook
|
|
33
|
+
* @see https://redwoodjs.com/docs/webhooks#webhooks
|
|
34
|
+
**/
|
|
35
|
+
export declare const mockSignedWebhook: ({ payload, signatureType, signatureHeader, secret, ...others }: MockedSignedWebhookParams) => APIGatewayProxyEvent;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=apiFunction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiFunction.d.ts","sourceRoot":"","sources":["../../../src/api/apiFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,2BAA2B,EAC3B,OAAO,EACR,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAGnE,UAAU,gBAAiB,SAAQ,OAAO,CAAC,oBAAoB,CAAC;IAC9D,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,OAAO,CAAC,EAAE,2BAA2B,CAAA;CACtC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,0HAUvB,gBAAgB,KAAG,oBAgCrB,CAAA;AAED;;;IAGI;AACJ,eAAO,MAAM,WAAW,QAAO,OAI9B,CAAA;AAED,UAAU,yBACR,SAAQ,IAAI,CAAC,gBAAgB,EAAE,WAAW,GAAG,iBAAiB,CAAC;IAC/D,aAAa,EAAE,OAAO,CAAC,sBAAsB,EAAE,cAAc,CAAC,CAAA;IAC9D,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;IAGI;AACJ,eAAO,MAAM,iBAAiB,mEAM3B,yBAAyB,yBAe3B,CAAA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var apiFunction_exports = {};
|
|
20
|
+
__export(apiFunction_exports, {
|
|
21
|
+
mockContext: () => mockContext,
|
|
22
|
+
mockHttpEvent: () => mockHttpEvent,
|
|
23
|
+
mockSignedWebhook: () => mockSignedWebhook
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(apiFunction_exports);
|
|
26
|
+
var import_webhooks = require("@cedarjs/api/webhooks");
|
|
27
|
+
const mockHttpEvent = ({
|
|
28
|
+
payload = null,
|
|
29
|
+
signature,
|
|
30
|
+
signatureHeader,
|
|
31
|
+
queryStringParameters = null,
|
|
32
|
+
httpMethod = "GET",
|
|
33
|
+
headers = {},
|
|
34
|
+
path = "",
|
|
35
|
+
isBase64Encoded = false,
|
|
36
|
+
...others
|
|
37
|
+
}) => {
|
|
38
|
+
if (signature && signatureHeader) {
|
|
39
|
+
headers[signatureHeader.toLocaleLowerCase()] = signature;
|
|
40
|
+
}
|
|
41
|
+
const payloadAsString = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
42
|
+
const body = payload === null ? null : isBase64Encoded ? Buffer.from(payloadAsString || "").toString("base64") : payloadAsString;
|
|
43
|
+
return {
|
|
44
|
+
body,
|
|
45
|
+
headers,
|
|
46
|
+
multiValueHeaders: {},
|
|
47
|
+
isBase64Encoded,
|
|
48
|
+
path,
|
|
49
|
+
pathParameters: null,
|
|
50
|
+
stageVariables: null,
|
|
51
|
+
httpMethod,
|
|
52
|
+
queryStringParameters,
|
|
53
|
+
// @ts-expect-error not required for mocks
|
|
54
|
+
requestContext: null,
|
|
55
|
+
// @ts-expect-error not required for mocks
|
|
56
|
+
resource: null,
|
|
57
|
+
multiValueQueryStringParameters: null,
|
|
58
|
+
...others
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
const mockContext = () => {
|
|
62
|
+
const context = {};
|
|
63
|
+
return context;
|
|
64
|
+
};
|
|
65
|
+
const mockSignedWebhook = ({
|
|
66
|
+
payload = null,
|
|
67
|
+
signatureType,
|
|
68
|
+
signatureHeader,
|
|
69
|
+
secret,
|
|
70
|
+
...others
|
|
71
|
+
}) => {
|
|
72
|
+
const payloadAsString = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
73
|
+
const signature = (0, import_webhooks.signPayload)(signatureType, {
|
|
74
|
+
payload: payloadAsString,
|
|
75
|
+
secret
|
|
76
|
+
});
|
|
77
|
+
return mockHttpEvent({
|
|
78
|
+
payload,
|
|
79
|
+
signature,
|
|
80
|
+
signatureHeader,
|
|
81
|
+
...others
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
+
0 && (module.exports = {
|
|
86
|
+
mockContext,
|
|
87
|
+
mockHttpEvent,
|
|
88
|
+
mockSignedWebhook
|
|
89
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directUrlHelpers.d.ts","sourceRoot":"","sources":["../../../src/api/directUrlHelpers.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,UAE3C;AAED,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,sBA2BlB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var directUrlHelpers_exports = {};
|
|
30
|
+
__export(directUrlHelpers_exports, {
|
|
31
|
+
checkAndReplaceDirectUrl: () => checkAndReplaceDirectUrl,
|
|
32
|
+
getDefaultDb: () => getDefaultDb
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(directUrlHelpers_exports);
|
|
35
|
+
var import_path = __toESM(require("path"), 1);
|
|
36
|
+
function getDefaultDb(rwjsCwd) {
|
|
37
|
+
return `file:${import_path.default.join(rwjsCwd, ".redwood", "test.db")}`;
|
|
38
|
+
}
|
|
39
|
+
function checkAndReplaceDirectUrl(prismaSchema, defaultDb) {
|
|
40
|
+
const directUrl = prismaSchema.match(PRISMA_DIRECT_URL_REGEXP);
|
|
41
|
+
if (!directUrl) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const directUrlEnvMatch = directUrl[0].match(BETWEEN_PARENTHESES_REGEXP);
|
|
45
|
+
if (!directUrlEnvMatch) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
"Error parsing `directUrl` from schema.prisma. Proceeding with this env var could be dangerous. Please check your schema.prisma file; if everything looks ok, file an issue."
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
const directUrlEnv = directUrlEnvMatch[2];
|
|
51
|
+
process.env[directUrlEnv] = process.env.TEST_DIRECT_URL || process.env.TEST_DATABASE_URL || defaultDb;
|
|
52
|
+
return directUrlEnv;
|
|
53
|
+
}
|
|
54
|
+
const PRISMA_DIRECT_URL_REGEXP = /directUrl(\s*)=(\s*)env\(('|")(.*)('|")\)/g;
|
|
55
|
+
const BETWEEN_PARENTHESES_REGEXP = /\(('|")([^)]+)('|")\)/;
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
checkAndReplaceDirectUrl,
|
|
59
|
+
getDefaultDb
|
|
60
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { A } from 'ts-toolbelt';
|
|
2
|
+
import type { DirectiveParams, ValidatorDirective, TransformerDirective } from '@cedarjs/graphql-server';
|
|
3
|
+
export { getDirectiveName } from '@cedarjs/graphql-server';
|
|
4
|
+
interface DirectiveMocker {
|
|
5
|
+
(directive: ValidatorDirective, executionMock: A.Compute<Omit<Partial<DirectiveParams>, 'resolvedValue'>>): any;
|
|
6
|
+
}
|
|
7
|
+
type TransformerMock = A.Compute<Omit<Partial<DirectiveParams>, 'resolvedValue'>> & {
|
|
8
|
+
mockedResolvedValue: any;
|
|
9
|
+
};
|
|
10
|
+
interface DirectiveMocker {
|
|
11
|
+
(directive: TransformerDirective, executionMock: TransformerMock): any;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @description
|
|
15
|
+
*
|
|
16
|
+
* Used for writing both synchronous and asynchronous directive tests e.g.
|
|
17
|
+
*
|
|
18
|
+
* - Transformer directives can be passed mockedResolvedValue
|
|
19
|
+
* - Validator directives should check for errors thrown in certain situations
|
|
20
|
+
* - Can provide args, directiveArgs and context to mock directive execution
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
*
|
|
24
|
+
* Synchronous transformer directive:
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* const mockExecution = mockRedwoodDirective(myTransformer, {
|
|
28
|
+
* context: currentUser,
|
|
29
|
+
* mockedResolvedValue: 'Original Value',
|
|
30
|
+
* })
|
|
31
|
+
*
|
|
32
|
+
* expect(mockExecution).not.toThrow()
|
|
33
|
+
* expect(mockExecution()).toEqual('Transformed Value')
|
|
34
|
+
* ```ts
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
*
|
|
38
|
+
* Asynchronous transformer directive:
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* const mockExecution = mockRedwoodDirective(myTransformer, {
|
|
42
|
+
* context: currentUser,
|
|
43
|
+
* mockedResolvedValue: 'Original Value',
|
|
44
|
+
* })
|
|
45
|
+
*
|
|
46
|
+
* await expect(mockExecution).resolves.not.toThrow()
|
|
47
|
+
* await expect(mockExecution()).resolves.toEqual('Transformed Value')
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare const mockRedwoodDirective: DirectiveMocker;
|
|
51
|
+
//# sourceMappingURL=directive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directive.d.ts","sourceRoot":"","sources":["../../../src/api/directive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,aAAa,CAAA;AAGpC,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAG1D,UAAU,eAAe;IACvB,CACE,SAAS,EAAE,kBAAkB,EAC7B,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,CAAC,GACxE,GAAG,CAAA;CACP;AAED,KAAK,eAAe,GAAG,CAAC,CAAC,OAAO,CAC9B,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,CAChD,GAAG;IACF,mBAAmB,EAAE,GAAG,CAAA;CACzB,CAAA;AAGD,UAAU,eAAe;IACvB,CAAC,SAAS,EAAE,oBAAoB,EAAE,aAAa,EAAE,eAAe,GAAG,GAAG,CAAA;CACvE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,oBAAoB,EAAE,eAmDlC,CAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var directive_exports = {};
|
|
20
|
+
__export(directive_exports, {
|
|
21
|
+
getDirectiveName: () => import_graphql_server2.getDirectiveName,
|
|
22
|
+
mockRedwoodDirective: () => mockRedwoodDirective
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(directive_exports);
|
|
25
|
+
var import_context = require("@cedarjs/context");
|
|
26
|
+
var import_graphql_server = require("@cedarjs/graphql-server");
|
|
27
|
+
var import_graphql_server2 = require("@cedarjs/graphql-server");
|
|
28
|
+
const mockRedwoodDirective = (directive, executionMock) => {
|
|
29
|
+
const { directiveArgs, context, ...others } = executionMock;
|
|
30
|
+
if (directive.onResolvedValue.constructor.name === "AsyncFunction") {
|
|
31
|
+
return async () => {
|
|
32
|
+
if (context !== void 0) {
|
|
33
|
+
(0, import_context.setContext)(context);
|
|
34
|
+
}
|
|
35
|
+
if (directive.type === import_graphql_server.DirectiveType.TRANSFORMER) {
|
|
36
|
+
const { mockedResolvedValue } = others;
|
|
37
|
+
return directive.onResolvedValue({
|
|
38
|
+
resolvedValue: mockedResolvedValue,
|
|
39
|
+
directiveArgs: directiveArgs ?? {},
|
|
40
|
+
context: import_context.context,
|
|
41
|
+
...others
|
|
42
|
+
});
|
|
43
|
+
} else {
|
|
44
|
+
await directive.onResolvedValue({
|
|
45
|
+
directiveArgs: directiveArgs ?? {},
|
|
46
|
+
context: import_context.context,
|
|
47
|
+
...others
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return () => {
|
|
53
|
+
if (context !== void 0) {
|
|
54
|
+
(0, import_context.setContext)(context);
|
|
55
|
+
}
|
|
56
|
+
if (directive.type === import_graphql_server.DirectiveType.TRANSFORMER) {
|
|
57
|
+
const { mockedResolvedValue } = others;
|
|
58
|
+
return directive.onResolvedValue({
|
|
59
|
+
resolvedValue: mockedResolvedValue,
|
|
60
|
+
directiveArgs: directiveArgs ?? {},
|
|
61
|
+
context: import_context.context,
|
|
62
|
+
...others
|
|
63
|
+
});
|
|
64
|
+
} else {
|
|
65
|
+
directive.onResolvedValue({
|
|
66
|
+
directiveArgs: directiveArgs ?? {},
|
|
67
|
+
context: import_context.context,
|
|
68
|
+
...others
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
getDirectiveName,
|
|
76
|
+
mockRedwoodDirective
|
|
77
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var api_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(api_exports);
|
|
18
|
+
__reExport(api_exports, require("./apiFunction.js"), module.exports);
|
|
19
|
+
__reExport(api_exports, require("./scenario.js"), module.exports);
|
|
20
|
+
__reExport(api_exports, require("./directive.js"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("./apiFunction.js"),
|
|
24
|
+
...require("./scenario.js"),
|
|
25
|
+
...require("./directive.js")
|
|
26
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { A } from 'ts-toolbelt';
|
|
2
|
+
/**
|
|
3
|
+
* Use this function to define your scenario.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* export const standard = defineScenario({
|
|
7
|
+
* user: {
|
|
8
|
+
* dom: {
|
|
9
|
+
* name: 'Dom Saadi',
|
|
10
|
+
* email: 'dom@cedarjs.com',
|
|
11
|
+
* },
|
|
12
|
+
* },
|
|
13
|
+
* })
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* export const standard = defineScenario<Prisma.CreateUserArgs>({
|
|
17
|
+
* user: {
|
|
18
|
+
* dom: {
|
|
19
|
+
* name: 'Dom Saadi',
|
|
20
|
+
* email: 'dom@cedarjs.com',
|
|
21
|
+
* },
|
|
22
|
+
* },
|
|
23
|
+
* })
|
|
24
|
+
*/
|
|
25
|
+
export declare const defineScenario: DefineScenario;
|
|
26
|
+
/**
|
|
27
|
+
* @example
|
|
28
|
+
* {
|
|
29
|
+
* dannyUser: {
|
|
30
|
+
* data: {
|
|
31
|
+
* id: 1,
|
|
32
|
+
* name: 'Danny',
|
|
33
|
+
* },
|
|
34
|
+
* },
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* krisUser: (scenario) => {
|
|
39
|
+
* return {
|
|
40
|
+
* data: {
|
|
41
|
+
* id: 2,
|
|
42
|
+
* name: 'Kris',
|
|
43
|
+
* },
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
*/
|
|
47
|
+
type ScenarioDefinitionMap<PrismaCreateType extends {
|
|
48
|
+
data: any;
|
|
49
|
+
}, ModelName extends string | number | symbol = string | number | symbol, TKeys extends string | number | symbol = string | number | symbol> = Record<TKeys, A.Compute<PrismaCreateType> | ((scenario: Record<ModelName, Record<TKeys, any>>) => A.Compute<PrismaCreateType>)>;
|
|
50
|
+
export interface DefineScenario {
|
|
51
|
+
<PrismaCreateType extends {
|
|
52
|
+
data: any;
|
|
53
|
+
}, ModelName extends string | number | symbol = string | number | symbol, TKeys extends string | number | symbol = string | number | symbol>(scenarioMap: Record<ModelName, ScenarioDefinitionMap<PrismaCreateType, ModelName, TKeys>>): Record<ModelName, Record<TKeys, any>>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Type of data seeded by the scenario. Use this type to get the 'strict' return type of defineScenario
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* import { Product } from '@prisma/client'
|
|
60
|
+
*
|
|
61
|
+
* // If you scenario looks like this:
|
|
62
|
+
* export const standard = defineScenario({
|
|
63
|
+
* product: {
|
|
64
|
+
* shirt: {
|
|
65
|
+
* id: 55,
|
|
66
|
+
* price: 10,
|
|
67
|
+
* },
|
|
68
|
+
* },
|
|
69
|
+
* })
|
|
70
|
+
*
|
|
71
|
+
* // Export the StandardScenario type as
|
|
72
|
+
* export StandardScenario = ScenarioData<Product, 'product'>
|
|
73
|
+
*
|
|
74
|
+
* // You can also define each of the keys in your scenario, so you get stricter type checking
|
|
75
|
+
* export StandardScenario = ScenarioData<Product, 'product', 'shirt'>
|
|
76
|
+
*/
|
|
77
|
+
export declare type ScenarioData<TModel, // the prisma model, imported from @prisma/client e.g. "Product"
|
|
78
|
+
TName extends string | number = string | number, // (optional) name of the prisma model e.g. "product"
|
|
79
|
+
TKeys extends string | number = string | number> = Record<TName, Record<TKeys, TModel>>;
|
|
80
|
+
interface TestFunctionWithScenario<TData> {
|
|
81
|
+
(scenario?: TData): Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
interface DescribeBlockWithGetScenario<TData> {
|
|
84
|
+
(getScenario: () => TData): void;
|
|
85
|
+
}
|
|
86
|
+
export interface Scenario {
|
|
87
|
+
(title: string, testFunction: TestFunctionWithScenario<any>): void;
|
|
88
|
+
}
|
|
89
|
+
export interface Scenario {
|
|
90
|
+
(namedScenario: string, title: string, testFunction: TestFunctionWithScenario<any>): void;
|
|
91
|
+
}
|
|
92
|
+
export interface Scenario {
|
|
93
|
+
only: Scenario;
|
|
94
|
+
}
|
|
95
|
+
export interface DescribeScenario {
|
|
96
|
+
<TData = any>(title: string, describeBlock: DescribeBlockWithGetScenario<TData>): void;
|
|
97
|
+
}
|
|
98
|
+
export interface DescribeScenario {
|
|
99
|
+
<TData>(title: string, describeBlock: DescribeBlockWithGetScenario<TData>): void;
|
|
100
|
+
}
|
|
101
|
+
export interface DescribeScenario {
|
|
102
|
+
<TData>(namedScenario: string, title: string, describeBlock: DescribeBlockWithGetScenario<TData>): void;
|
|
103
|
+
}
|
|
104
|
+
export interface DescribeScenario {
|
|
105
|
+
only: DescribeScenario;
|
|
106
|
+
}
|
|
107
|
+
export {};
|
|
108
|
+
//# sourceMappingURL=scenario.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenario.d.ts","sourceRoot":"","sources":["../../../src/api/scenario.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var scenario_exports = {};
|
|
20
|
+
__export(scenario_exports, {
|
|
21
|
+
defineScenario: () => defineScenario
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(scenario_exports);
|
|
24
|
+
const defineScenario = (data) => {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
defineScenario
|
|
30
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
type AsymmetricMatcher = {
|
|
2
|
+
$$typeof: symbol;
|
|
3
|
+
};
|
|
4
|
+
type ExpectedValue = any[] | any | AsymmetricMatcher;
|
|
5
|
+
type ExpectedKey = string | RegExp;
|
|
6
|
+
declare global {
|
|
7
|
+
namespace jest {
|
|
8
|
+
interface Matchers<R> {
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* Use this helper to simplify testing your InMemoryCache client.
|
|
12
|
+
*
|
|
13
|
+
* The expected value you provide will be serialized and deseriliazed for you.
|
|
14
|
+
*
|
|
15
|
+
* NOTE: Does not support partialMatch - use cacheClient.contents or test with a key!
|
|
16
|
+
* @param expectedValue The value that is cached, must be serializable
|
|
17
|
+
*/
|
|
18
|
+
toHaveCached(expectedValue: unknown): R;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* Use this helper to simplify testing your InMemoryCache client.
|
|
22
|
+
*
|
|
23
|
+
*
|
|
24
|
+
* @param cacheKey They key that your value is cached under
|
|
25
|
+
* @param expectedValue The expected value. Can be a jest asymmetric matcher (using `partialMatch`)
|
|
26
|
+
*/
|
|
27
|
+
toHaveCached(cacheKey: ExpectedKey, expectedValue: ExpectedValue): R;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* This is just syntactic sugar, to help with testing cache contents.
|
|
33
|
+
*
|
|
34
|
+
* If you pass an array, it will check arrays for a partial match of the object.
|
|
35
|
+
*
|
|
36
|
+
* If you pass an object, it will check for a partial match of the object.
|
|
37
|
+
*
|
|
38
|
+
* Useful when you don't want to compare dates/auto-generated ids etc.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* expect(testCacheClient.contents).toContainEqual(partialMatch({ title: 'Only look for this title'}))
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* expect(testCacheClient.contents).toContainEqual(partialMatch([{id: 1}, {id: 2}]))
|
|
45
|
+
*
|
|
46
|
+
* @param value Object or Array of object to match
|
|
47
|
+
*/
|
|
48
|
+
export declare const partialMatch: (value: Record<any, any> | Record<any, any>[]) => any;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|