@cedarjs/testing 0.1.1 → 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 +78 -14
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cache/index.ts"],"names":[],"mappings":"AAEA,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,KAAK,aAAa,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,iBAAiB,CAAA;AACpD,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,CAAA;AAwHlC,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,IAAI,CAAC;QACb,UAAU,QAAQ,CAAC,CAAC;YAClB;;;;;;;;eAQG;YACH,YAAY,CAAC,aAAa,EAAE,OAAO,GAAG,CAAC,CAAA;YAEvC;;;;;;;eAOG;YACH,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,GAAG,CAAC,CAAA;SACrE;KACF;CACF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,QAIxE,CAAA"}
|
|
@@ -0,0 +1,104 @@
|
|
|
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
|
+
expect.extend({
|
|
25
|
+
toHaveCached(cacheClient, keyOrExpectedValue, expectedValue) {
|
|
26
|
+
let value;
|
|
27
|
+
let regexKey;
|
|
28
|
+
let stringKey;
|
|
29
|
+
if (_isKVPair(keyOrExpectedValue, expectedValue)) {
|
|
30
|
+
if (keyOrExpectedValue instanceof RegExp) {
|
|
31
|
+
regexKey = keyOrExpectedValue;
|
|
32
|
+
} else {
|
|
33
|
+
stringKey = keyOrExpectedValue;
|
|
34
|
+
}
|
|
35
|
+
value = expectedValue;
|
|
36
|
+
} else {
|
|
37
|
+
value = keyOrExpectedValue;
|
|
38
|
+
}
|
|
39
|
+
let foundKVPair;
|
|
40
|
+
let found = false;
|
|
41
|
+
if (stringKey) {
|
|
42
|
+
return _checkValueForKey(cacheClient, stringKey, value);
|
|
43
|
+
} else {
|
|
44
|
+
for (const [cachedKey, cachedValue] of Object.entries(
|
|
45
|
+
cacheClient.storage
|
|
46
|
+
)) {
|
|
47
|
+
if (found) {
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
if (regexKey?.test(cachedKey)) {
|
|
51
|
+
found = true;
|
|
52
|
+
foundKVPair = { key: cachedKey, value: cachedValue.value };
|
|
53
|
+
} else {
|
|
54
|
+
found = cachedValue.value === JSON.stringify(value);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (foundKVPair) {
|
|
59
|
+
return _checkValueForKey(cacheClient, foundKVPair.key, value);
|
|
60
|
+
}
|
|
61
|
+
if (found) {
|
|
62
|
+
return {
|
|
63
|
+
pass: true,
|
|
64
|
+
message: () => "Found cached value"
|
|
65
|
+
};
|
|
66
|
+
} else {
|
|
67
|
+
return {
|
|
68
|
+
pass: false,
|
|
69
|
+
message: () => `Expected Cached Value: ${this.utils.printExpected(
|
|
70
|
+
JSON.stringify(value)
|
|
71
|
+
)}
|
|
72
|
+
Cache Contents: ${this.utils.printReceived(cacheClient.storage)}`
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const _isKVPair = (keyOrCachedValue, cachedValue) => {
|
|
78
|
+
return !!cachedValue && !!keyOrCachedValue;
|
|
79
|
+
};
|
|
80
|
+
const _checkValueForKey = (cacheClient, cacheKey, expectedValue) => {
|
|
81
|
+
try {
|
|
82
|
+
const cachedStringValue = cacheClient.storage[cacheKey]?.value;
|
|
83
|
+
const expectedValueOrMatcher = expectedValue?.$$typeof === Symbol.for("jest.asymmetricMatcher") ? expectedValue : JSON.parse(JSON.stringify(expectedValue));
|
|
84
|
+
expect(
|
|
85
|
+
cachedStringValue ? JSON.parse(cachedStringValue) : void 0
|
|
86
|
+
).toEqual(expectedValueOrMatcher);
|
|
87
|
+
return {
|
|
88
|
+
pass: true,
|
|
89
|
+
message: () => `Found cached value with ${cacheKey}`
|
|
90
|
+
};
|
|
91
|
+
} catch (e) {
|
|
92
|
+
return {
|
|
93
|
+
pass: false,
|
|
94
|
+
message: () => e.message
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const partialMatch = (value) => {
|
|
99
|
+
return Array.isArray(value) ? expect.arrayContaining(value.map((v) => expect.objectContaining(v))) : expect.objectContaining(value);
|
|
100
|
+
};
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
partialMatch
|
|
104
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockParamsProvider.d.ts","sourceRoot":"","sources":["../../../src/web/MockParamsProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,UAAU,KAAK;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B;AAED,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAS9C,CAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 MockParamsProvider_exports = {};
|
|
30
|
+
__export(MockParamsProvider_exports, {
|
|
31
|
+
MockParamsProvider: () => MockParamsProvider
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(MockParamsProvider_exports);
|
|
34
|
+
var import_react = __toESM(require("react"), 1);
|
|
35
|
+
var import_router = require("@cedarjs/router");
|
|
36
|
+
const MockParamsProvider = ({ children }) => {
|
|
37
|
+
const location = (0, import_router.useLocation)();
|
|
38
|
+
const searchParams = (0, import_router.parseSearch)(location.search);
|
|
39
|
+
return /* @__PURE__ */ import_react.default.createElement(import_router.ParamsContext.Provider, { value: { params: { ...searchParams } } }, children);
|
|
40
|
+
};
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
MockParamsProvider
|
|
44
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NOTE: This module should not contain any nodejs functionality,
|
|
3
|
+
* because it's also used by Storybook in the browser.
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
export declare const MockProviders: React.FunctionComponent<{
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=MockProviders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockProviders.d.ts","sourceRoot":"","sources":["../../../src/web/MockProviders.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,OAAO,CAAA;AAuBzB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAClD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAWA,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
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 MockProviders_exports = {};
|
|
30
|
+
__export(MockProviders_exports, {
|
|
31
|
+
MockProviders: () => MockProviders
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(MockProviders_exports);
|
|
34
|
+
var import_react = __toESM(require("react"), 1);
|
|
35
|
+
var import_router = require("@cedarjs/router");
|
|
36
|
+
var import_web = require("@cedarjs/web");
|
|
37
|
+
var import_apollo = require("@cedarjs/web/apollo");
|
|
38
|
+
var import_mockAuth = require("./mockAuth.js");
|
|
39
|
+
var import_MockParamsProvider = require("./MockParamsProvider.js");
|
|
40
|
+
let UserRoutes;
|
|
41
|
+
try {
|
|
42
|
+
const userRoutesModule = require("~__REDWOOD__USER_ROUTES_FOR_MOCK");
|
|
43
|
+
UserRoutes = userRoutesModule.default;
|
|
44
|
+
} catch {
|
|
45
|
+
UserRoutes = () => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null);
|
|
46
|
+
}
|
|
47
|
+
const MockProviders = ({ children }) => {
|
|
48
|
+
return /* @__PURE__ */ import_react.default.createElement(import_web.RedwoodProvider, { titleTemplate: "%PageTitle | %AppTitle" }, /* @__PURE__ */ import_react.default.createElement(import_apollo.RedwoodApolloProvider, { useAuth: import_mockAuth.useAuth }, /* @__PURE__ */ import_react.default.createElement(UserRoutes, null), /* @__PURE__ */ import_react.default.createElement(import_router.LocationProvider, null, /* @__PURE__ */ import_react.default.createElement(import_MockParamsProvider.MockParamsProvider, null, children))));
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
MockProviders
|
|
53
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { RouterProps } from '@cedarjs/router/dist/router';
|
|
3
|
+
export * from '@cedarjs/router/dist/index';
|
|
4
|
+
export declare const routes: {
|
|
5
|
+
[routeName: string]: () => string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* We overwrite the default `Router` export (see jest-preset). So every import
|
|
9
|
+
* of @cedarjs/router will import this Router instead
|
|
10
|
+
*
|
|
11
|
+
* This router populates the `routes.<pageName>()` utility object.
|
|
12
|
+
*/
|
|
13
|
+
export declare const Router: React.FC<RouterProps>;
|
|
14
|
+
//# sourceMappingURL=MockRouter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockRouter.d.ts","sourceRoot":"","sources":["../../../src/web/MockRouter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAE9D,cAAc,4BAA4B,CAAA;AAE1C,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,MAAM,CAAA;CAAO,CAAA;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAcxC,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var MockRouter_exports = {};
|
|
21
|
+
__export(MockRouter_exports, {
|
|
22
|
+
Router: () => Router,
|
|
23
|
+
routes: () => routes
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(MockRouter_exports);
|
|
26
|
+
var import_react_util = require("@cedarjs/router/dist/react-util");
|
|
27
|
+
var import_route_validators = require("@cedarjs/router/dist/route-validators");
|
|
28
|
+
var import_util = require("@cedarjs/router/dist/util");
|
|
29
|
+
__reExport(MockRouter_exports, require("@cedarjs/router/dist/index"), module.exports);
|
|
30
|
+
const routes = {};
|
|
31
|
+
const Router = ({ children }) => {
|
|
32
|
+
const flatChildArray = (0, import_react_util.flattenAll)(children);
|
|
33
|
+
flatChildArray.forEach((child) => {
|
|
34
|
+
if ((0, import_route_validators.isValidRoute)(child)) {
|
|
35
|
+
const { name, path } = child.props;
|
|
36
|
+
if (name && path) {
|
|
37
|
+
routes[name] = (args = {}) => (0, import_util.replaceParams)(path, args);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return null;
|
|
42
|
+
};
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
Router,
|
|
46
|
+
routes,
|
|
47
|
+
...require("@cedarjs/router/dist/index")
|
|
48
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RenderResult, RenderOptions, RenderHookOptions, RenderHookResult } from '@testing-library/react';
|
|
3
|
+
export type CustomRenderHookOptions<Props> = RenderHookOptions<Props>;
|
|
4
|
+
export declare const customRender: (ui: React.ReactElement, options?: RenderOptions) => RenderResult;
|
|
5
|
+
export declare const customRenderHook: <Props, Result>(render: (props: Props) => Result, options?: CustomRenderHookOptions<Props>) => RenderHookResult<Result, Props>;
|
|
6
|
+
//# sourceMappingURL=customRender.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customRender.d.ts","sourceRoot":"","sources":["../../../src/web/customRender.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,wBAAwB,CAAA;AAI/B,MAAM,MAAM,uBAAuB,CAAC,KAAK,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAA;AAErE,eAAO,MAAM,YAAY,OACnB,KAAK,CAAC,YAAY,YACb,aAAa,KACrB,YAKF,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,KAAK,EAAE,MAAM,UACpC,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,YACtB,uBAAuB,CAAC,KAAK,CAAC,KACvC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAKhC,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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 customRender_exports = {};
|
|
30
|
+
__export(customRender_exports, {
|
|
31
|
+
customRender: () => customRender,
|
|
32
|
+
customRenderHook: () => customRenderHook
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(customRender_exports);
|
|
35
|
+
var import_react = __toESM(require("react"), 1);
|
|
36
|
+
var import_react2 = require("@testing-library/react");
|
|
37
|
+
var import_MockProviders = require("./MockProviders.js");
|
|
38
|
+
const customRender = (ui, options = {}) => {
|
|
39
|
+
return (0, import_react2.render)(ui, {
|
|
40
|
+
wrapper: (props) => /* @__PURE__ */ import_react.default.createElement(import_MockProviders.MockProviders, { ...props }),
|
|
41
|
+
...options
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const customRenderHook = (render2, options) => {
|
|
45
|
+
return (0, import_react2.renderHook)(render2, {
|
|
46
|
+
wrapper: (props) => /* @__PURE__ */ import_react.default.createElement(import_MockProviders.MockProviders, { ...props }),
|
|
47
|
+
...options
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
customRender,
|
|
53
|
+
customRenderHook
|
|
54
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* configure Jest to gracefully handle asset files such as stylesheets and images.
|
|
3
|
+
* Usually, these files aren't particularly useful in tests so we can safely mock them out.
|
|
4
|
+
* See: https://jestjs.io/docs/en/webpack#handling-static-assets
|
|
5
|
+
* See: https://github.com/cedarjs/cedar/blob/4637f61d5e6aeb907d4a17217ab643cfb4d4ebe4/packages/testing/config/jest/web/jest-preset.js#L77-L78
|
|
6
|
+
*/
|
|
7
|
+
declare const _default: "fileMock";
|
|
8
|
+
export default _default;
|
|
9
|
+
//# sourceMappingURL=fileMock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileMock.d.ts","sourceRoot":"","sources":["../../../src/web/fileMock.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AACH,wBAAyB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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 fileMock_exports = {};
|
|
20
|
+
__export(fileMock_exports, {
|
|
21
|
+
default: () => fileMock_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(fileMock_exports);
|
|
24
|
+
var fileMock_default = "fileMock";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findCellMocks.d.ts","sourceRoot":"","sources":["../../../src/web/findCellMocks.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gBAAiB,MAAM,aAOhD,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 findCellMocks_exports = {};
|
|
30
|
+
__export(findCellMocks_exports, {
|
|
31
|
+
findCellMocks: () => findCellMocks
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(findCellMocks_exports);
|
|
34
|
+
var import_fast_glob = __toESM(require("fast-glob"), 1);
|
|
35
|
+
const findCellMocks = (webBasePath) => {
|
|
36
|
+
return import_fast_glob.default.sync("**/*Cell/*.mock.{js,ts,jsx,tsx}", {
|
|
37
|
+
cwd: webBasePath,
|
|
38
|
+
ignore: ["node_modules"],
|
|
39
|
+
absolute: true
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
findCellMocks
|
|
45
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { mockGraphQLQuery as _mockGraphQLQuery, mockGraphQLMutation as _mockGraphQLMutation } from './mockRequests.js';
|
|
2
|
+
declare global {
|
|
3
|
+
const mockGraphQLQuery: typeof _mockGraphQLQuery;
|
|
4
|
+
const mockGraphQLMutation: typeof _mockGraphQLMutation;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=global.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../src/web/global.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,IAAI,iBAAiB,EACrC,mBAAmB,IAAI,oBAAoB,EAC5C,MAAM,mBAAmB,CAAA;AAE1B,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,gBAAgB,EAAE,OAAO,iBAAiB,CAAA;IAChD,MAAM,mBAAmB,EAAE,OAAO,oBAAoB,CAAA;CAGvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from '@testing-library/react';
|
|
2
|
+
export { customRender as render, customRenderHook as renderHook, } from './customRender.js';
|
|
3
|
+
export { MockProviders } from './MockProviders.js';
|
|
4
|
+
export { useAuth } from './mockAuth.js';
|
|
5
|
+
export * from './mockRequests.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA;AAGtC,OAAO,EACL,YAAY,IAAI,MAAM,EACtB,gBAAgB,IAAI,UAAU,GAC/B,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var web_exports = {};
|
|
21
|
+
__export(web_exports, {
|
|
22
|
+
MockProviders: () => import_MockProviders.MockProviders,
|
|
23
|
+
render: () => import_customRender.customRender,
|
|
24
|
+
renderHook: () => import_customRender.customRenderHook,
|
|
25
|
+
useAuth: () => import_mockAuth.useAuth
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(web_exports);
|
|
28
|
+
__reExport(web_exports, require("@testing-library/react"), module.exports);
|
|
29
|
+
var import_customRender = require("./customRender.js");
|
|
30
|
+
var import_MockProviders = require("./MockProviders.js");
|
|
31
|
+
var import_mockAuth = require("./mockAuth.js");
|
|
32
|
+
__reExport(web_exports, require("./mockRequests.js"), module.exports);
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
MockProviders,
|
|
36
|
+
render,
|
|
37
|
+
renderHook,
|
|
38
|
+
useAuth,
|
|
39
|
+
...require("@testing-library/react"),
|
|
40
|
+
...require("./mockRequests.js")
|
|
41
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export * from '@cedarjs/auth';
|
|
3
|
+
interface Props {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare function useAuth(): {
|
|
7
|
+
loading: boolean;
|
|
8
|
+
isAuthenticated: boolean;
|
|
9
|
+
logIn: () => Promise<void>;
|
|
10
|
+
logOut: () => Promise<void>;
|
|
11
|
+
signUp: () => Promise<void>;
|
|
12
|
+
currentUser: Record<string, unknown> | null;
|
|
13
|
+
userMetadata: Record<string, unknown> | null;
|
|
14
|
+
getToken: () => Promise<null>;
|
|
15
|
+
getCurrentUser: () => Promise<Record<string, unknown> | null>;
|
|
16
|
+
hasRole: (roles: string | string[]) => boolean;
|
|
17
|
+
reauthenticate: () => Promise<void>;
|
|
18
|
+
forgotPassword: () => Promise<void>;
|
|
19
|
+
resetPassword: () => Promise<void>;
|
|
20
|
+
validateResetToken: () => Promise<void>;
|
|
21
|
+
type: string;
|
|
22
|
+
client: undefined;
|
|
23
|
+
hasError: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare const createAuthentication: () => {
|
|
26
|
+
AuthProvider: React.FC<Props>;
|
|
27
|
+
useAuth: typeof useAuth;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=mockAuth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockAuth.d.ts","sourceRoot":"","sources":["../../../src/web/mockAuth.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,cAAc,eAAe,CAAA;AAI7B,UAAU,KAAK;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAYD,wBAAgB,OAAO;;;;;;;;;;qBAWF,MAAM,GAAG,MAAM,EAAE;;;;;;;;EAmBrC;AAED,eAAO,MAAM,oBAAoB;;;CAEhC,CAAA"}
|