@cedarjs/testing 7.0.0-canary.2989 → 7.0.0-canary.2991
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/package.json +21 -52
- package/dist/cjs/api/apiFunction.d.ts +0 -37
- package/dist/cjs/api/apiFunction.d.ts.map +0 -1
- package/dist/cjs/api/apiFunction.js +0 -89
- package/dist/cjs/api/checkTestDatabase.d.ts +0 -23
- package/dist/cjs/api/checkTestDatabase.d.ts.map +0 -1
- package/dist/cjs/api/checkTestDatabase.js +0 -69
- package/dist/cjs/api/directive.d.ts +0 -51
- package/dist/cjs/api/directive.d.ts.map +0 -1
- package/dist/cjs/api/directive.js +0 -77
- package/dist/cjs/api/index.d.ts +0 -4
- package/dist/cjs/api/index.d.ts.map +0 -1
- package/dist/cjs/api/index.js +0 -26
- package/dist/cjs/api/mockContext.d.ts +0 -5
- package/dist/cjs/api/mockContext.d.ts.map +0 -1
- package/dist/cjs/api/mockContext.js +0 -58
- package/dist/cjs/api/scenario.d.ts +0 -108
- package/dist/cjs/api/scenario.d.ts.map +0 -1
- package/dist/cjs/api/scenario.js +0 -30
- package/dist/cjs/api/vitest/CedarApiVitestEnv.js +0 -75
- package/dist/cjs/api/vitest/index.js +0 -34
- package/dist/cjs/api/vitest/vite-plugin-auto-import.js +0 -71
- package/dist/cjs/api/vitest/vite-plugin-cedar-vitest-api-config.js +0 -69
- package/dist/cjs/api/vitest/vite-plugin-track-db-imports.js +0 -47
- package/dist/cjs/api/vitest/vitest-api.setup.js +0 -270
- package/dist/cjs/cache/index.d.ts +0 -50
- package/dist/cjs/cache/index.d.ts.map +0 -1
- package/dist/cjs/cache/index.js +0 -104
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/web/MockParamsProvider.d.ts +0 -7
- package/dist/cjs/web/MockParamsProvider.d.ts.map +0 -1
- package/dist/cjs/web/MockParamsProvider.js +0 -44
- package/dist/cjs/web/MockProviders.d.ts +0 -5
- package/dist/cjs/web/MockProviders.d.ts.map +0 -1
- package/dist/cjs/web/MockProviders.js +0 -66
- package/dist/cjs/web/MockRouter.d.ts +0 -11
- package/dist/cjs/web/MockRouter.d.ts.map +0 -1
- package/dist/cjs/web/MockRouter.js +0 -48
- package/dist/cjs/web/customRender.d.ts +0 -6
- package/dist/cjs/web/customRender.d.ts.map +0 -1
- package/dist/cjs/web/customRender.js +0 -54
- package/dist/cjs/web/findCellMocks.d.ts +0 -2
- package/dist/cjs/web/findCellMocks.d.ts.map +0 -1
- package/dist/cjs/web/findCellMocks.js +0 -45
- package/dist/cjs/web/globRoutesImporter.d.ts +0 -13
- package/dist/cjs/web/globRoutesImporter.d.ts.map +0 -1
- package/dist/cjs/web/globRoutesImporter.js +0 -46
- package/dist/cjs/web/global.d.ts +0 -6
- package/dist/cjs/web/global.d.ts.map +0 -1
- package/dist/cjs/web/global.js +0 -1
- package/dist/cjs/web/index.d.ts +0 -6
- package/dist/cjs/web/index.d.ts.map +0 -1
- package/dist/cjs/web/index.js +0 -41
- package/dist/cjs/web/mockAuth.d.ts +0 -29
- package/dist/cjs/web/mockAuth.d.ts.map +0 -1
- package/dist/cjs/web/mockAuth.js +0 -89
- package/dist/cjs/web/mockRequests.d.ts +0 -72
- package/dist/cjs/web/mockRequests.d.ts.map +0 -1
- package/dist/cjs/web/mockRequests.js +0 -210
- package/dist/cjs/web/vitest/index.js +0 -37
- package/dist/cjs/web/vitest/vite-plugin-auto-import.js +0 -60
- package/dist/cjs/web/vitest/vite-plugin-cedar-vitest-web-config.js +0 -51
- package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.js +0 -42
- package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.js +0 -43
- package/dist/cjs/web/vitest/vitest-web.setup.js +0 -19
|
@@ -1,270 +0,0 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
}
|
|
14
|
-
return to;
|
|
15
|
-
};
|
|
16
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
|
-
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
25
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
26
|
-
var import_vitest = require("vitest");
|
|
27
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
28
|
-
var import_api = require("@cedarjs/testing/api");
|
|
29
|
-
const mockContextStore = import_vitest.vi.hoisted(() => /* @__PURE__ */ new Map());
|
|
30
|
-
const mockContext = import_vitest.vi.hoisted(
|
|
31
|
-
() => new Proxy(
|
|
32
|
-
{},
|
|
33
|
-
{
|
|
34
|
-
get: (_target, prop) => {
|
|
35
|
-
if (prop === "toJSON") {
|
|
36
|
-
return () => mockContextStore.get("context");
|
|
37
|
-
}
|
|
38
|
-
return mockContextStore.get("context")[prop];
|
|
39
|
-
},
|
|
40
|
-
set: (_target, prop, value) => {
|
|
41
|
-
const ctx = mockContextStore.get("context");
|
|
42
|
-
ctx[prop] = value;
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
)
|
|
47
|
-
);
|
|
48
|
-
import_vitest.vi.mock("@cedarjs/context", () => {
|
|
49
|
-
return {
|
|
50
|
-
context: mockContext,
|
|
51
|
-
setContext: (newContext) => {
|
|
52
|
-
mockContextStore.set("context", newContext);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
});
|
|
56
|
-
(0, import_vitest.beforeEach)(() => {
|
|
57
|
-
mockContextStore.set("context", {});
|
|
58
|
-
});
|
|
59
|
-
globalThis.mockCurrentUser = (currentUser) => {
|
|
60
|
-
mockContextStore.set("context", { currentUser });
|
|
61
|
-
};
|
|
62
|
-
globalThis.defineScenario = import_api.defineScenario;
|
|
63
|
-
const cedarPaths = (0, import_project_config.getPaths)();
|
|
64
|
-
const HANDLED_ERRORS = [1451, 1811, 23001, 23503];
|
|
65
|
-
const TEARDOWN_CACHE_PATH = import_node_path.default.join(
|
|
66
|
-
cedarPaths.generated.base,
|
|
67
|
-
"scenarioTeardown.json"
|
|
68
|
-
);
|
|
69
|
-
const DEFAULT_SCENARIO = "standard";
|
|
70
|
-
let teardownOrder = [];
|
|
71
|
-
let originalTeardownOrder = [];
|
|
72
|
-
function buildScenario(itFunc) {
|
|
73
|
-
return (...args) => {
|
|
74
|
-
let scenarioName;
|
|
75
|
-
let testName;
|
|
76
|
-
let testFunc;
|
|
77
|
-
if (args.length === 3) {
|
|
78
|
-
;
|
|
79
|
-
[scenarioName, testName, testFunc] = args;
|
|
80
|
-
} else if (args.length === 2) {
|
|
81
|
-
scenarioName = DEFAULT_SCENARIO;
|
|
82
|
-
[testName, testFunc] = args;
|
|
83
|
-
} else {
|
|
84
|
-
throw new Error("scenario() requires 2 or 3 arguments");
|
|
85
|
-
}
|
|
86
|
-
return itFunc(testName, async ({ task }) => {
|
|
87
|
-
const testPath = task.file.filepath;
|
|
88
|
-
const { scenario } = await loadScenarios(testPath, scenarioName);
|
|
89
|
-
const scenarioData = await seedScenario(scenario);
|
|
90
|
-
try {
|
|
91
|
-
const result = await testFunc(scenarioData);
|
|
92
|
-
return result;
|
|
93
|
-
} finally {
|
|
94
|
-
await teardown();
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
function buildDescribeScenario(describeFunc) {
|
|
100
|
-
return (...args) => {
|
|
101
|
-
let scenarioName;
|
|
102
|
-
let describeBlockName;
|
|
103
|
-
let describeBlock;
|
|
104
|
-
if (args.length === 3) {
|
|
105
|
-
;
|
|
106
|
-
[scenarioName, describeBlockName, describeBlock] = args;
|
|
107
|
-
} else if (args.length === 2) {
|
|
108
|
-
scenarioName = DEFAULT_SCENARIO;
|
|
109
|
-
[describeBlockName, describeBlock] = args;
|
|
110
|
-
} else {
|
|
111
|
-
throw new Error("describeScenario() requires 2 or 3 arguments");
|
|
112
|
-
}
|
|
113
|
-
return describeFunc(describeBlockName, () => {
|
|
114
|
-
let scenarioData;
|
|
115
|
-
(0, import_vitest.beforeAll)(async ({}, suite) => {
|
|
116
|
-
const testPath = suite.file.filepath;
|
|
117
|
-
const { scenario } = await loadScenarios(testPath, scenarioName);
|
|
118
|
-
scenarioData = await seedScenario(scenario);
|
|
119
|
-
});
|
|
120
|
-
(0, import_vitest.afterAll)(async () => {
|
|
121
|
-
await teardown();
|
|
122
|
-
});
|
|
123
|
-
const getScenario = () => scenarioData;
|
|
124
|
-
describeBlock(getScenario);
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
async function configureTeardown() {
|
|
129
|
-
if (!wasDbImported()) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const { getDMMF } = await import("@prisma/internals");
|
|
133
|
-
const result = await (0, import_project_config.getPrismaSchemas)();
|
|
134
|
-
const schema = await getDMMF({ datamodel: result.schemas });
|
|
135
|
-
const schemaModels = schema.datamodel.models.map((m) => {
|
|
136
|
-
return m.dbName || m.name;
|
|
137
|
-
});
|
|
138
|
-
if (import_node_fs.default.existsSync(TEARDOWN_CACHE_PATH)) {
|
|
139
|
-
teardownOrder = JSON.parse(import_node_fs.default.readFileSync(TEARDOWN_CACHE_PATH).toString());
|
|
140
|
-
}
|
|
141
|
-
if (teardownOrder.length !== schemaModels.length) {
|
|
142
|
-
teardownOrder = schemaModels;
|
|
143
|
-
}
|
|
144
|
-
originalTeardownOrder = deepCopy(teardownOrder);
|
|
145
|
-
}
|
|
146
|
-
(0, import_vitest.beforeAll)(async () => {
|
|
147
|
-
await configureTeardown();
|
|
148
|
-
});
|
|
149
|
-
(0, import_vitest.afterAll)(() => {
|
|
150
|
-
globalThis.__cedarjs_db_imported__ = false;
|
|
151
|
-
});
|
|
152
|
-
async function teardown() {
|
|
153
|
-
if (!wasDbImported()) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
const quoteStyle2 = await getQuoteStyle();
|
|
157
|
-
const projectDb = await getProjectDb();
|
|
158
|
-
for (const modelName of teardownOrder) {
|
|
159
|
-
try {
|
|
160
|
-
const query = `DELETE FROM ${quoteStyle2}${modelName}${quoteStyle2}`;
|
|
161
|
-
await projectDb.$executeRawUnsafe(query);
|
|
162
|
-
} catch (e) {
|
|
163
|
-
console.error("teardown error\n", e);
|
|
164
|
-
const match = isErrorWithMessage(e) && e.message.match(/Code: `(\d+)`/);
|
|
165
|
-
if (match && HANDLED_ERRORS.includes(parseInt(match[1]))) {
|
|
166
|
-
const index = teardownOrder.indexOf(modelName);
|
|
167
|
-
teardownOrder[index] = null;
|
|
168
|
-
teardownOrder.push(modelName);
|
|
169
|
-
} else {
|
|
170
|
-
throw e;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
teardownOrder = teardownOrder.filter((val) => val);
|
|
175
|
-
if (!isIdenticalArray(teardownOrder, originalTeardownOrder)) {
|
|
176
|
-
originalTeardownOrder = deepCopy(teardownOrder);
|
|
177
|
-
import_node_fs.default.writeFileSync(TEARDOWN_CACHE_PATH, JSON.stringify(teardownOrder));
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
const seedScenario = async (scenario) => {
|
|
181
|
-
if (scenario) {
|
|
182
|
-
const scenarios = {};
|
|
183
|
-
const projectDb = await getProjectDb();
|
|
184
|
-
for (const [model, namedFixtures] of Object.entries(scenario)) {
|
|
185
|
-
scenarios[model] = {};
|
|
186
|
-
for (const [name, createArgs] of Object.entries(namedFixtures)) {
|
|
187
|
-
if (typeof createArgs === "function") {
|
|
188
|
-
scenarios[model][name] = await projectDb[model].create(
|
|
189
|
-
createArgs(scenarios)
|
|
190
|
-
);
|
|
191
|
-
} else {
|
|
192
|
-
scenarios[model][name] = await projectDb[model].create(createArgs);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return scenarios;
|
|
197
|
-
} else {
|
|
198
|
-
return {};
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
async function loadScenarios(testPath, scenarioName) {
|
|
202
|
-
const testFileDir = import_node_path.default.parse(testPath);
|
|
203
|
-
const testFileNameParts = testFileDir.name.split(".");
|
|
204
|
-
const testFilePath = `${testFileDir.dir}/${testFileNameParts.slice(0, testFileNameParts.length - 1).join(".")}.scenarios`;
|
|
205
|
-
let allScenarios;
|
|
206
|
-
let scenario;
|
|
207
|
-
try {
|
|
208
|
-
allScenarios = await import(testFilePath);
|
|
209
|
-
} catch (e) {
|
|
210
|
-
if (isErrorWithCode(e)) {
|
|
211
|
-
if (e instanceof Error) {
|
|
212
|
-
throw e;
|
|
213
|
-
} else {
|
|
214
|
-
console.error("unexpected error type", e);
|
|
215
|
-
throw e;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
if (allScenarios) {
|
|
220
|
-
if (allScenarios[scenarioName]) {
|
|
221
|
-
scenario = allScenarios[scenarioName];
|
|
222
|
-
} else {
|
|
223
|
-
throw new Error(
|
|
224
|
-
`UndefinedScenario: There is no scenario named "${scenarioName}" in ${testFilePath}.{js,ts}`
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
return { scenario };
|
|
229
|
-
}
|
|
230
|
-
const wasDbImported = () => {
|
|
231
|
-
return Boolean(globalThis.__cedarjs_db_imported__);
|
|
232
|
-
};
|
|
233
|
-
let quoteStyle;
|
|
234
|
-
async function getQuoteStyle() {
|
|
235
|
-
const { getConfig: getPrismaConfig } = await import("@prisma/internals");
|
|
236
|
-
const result = await (0, import_project_config.getPrismaSchemas)();
|
|
237
|
-
if (!quoteStyle) {
|
|
238
|
-
const config = await getPrismaConfig({
|
|
239
|
-
datamodel: result.schemas
|
|
240
|
-
});
|
|
241
|
-
switch (config.datasources?.[0]?.provider) {
|
|
242
|
-
case "mysql":
|
|
243
|
-
quoteStyle = "`";
|
|
244
|
-
break;
|
|
245
|
-
default:
|
|
246
|
-
quoteStyle = '"';
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
return quoteStyle;
|
|
250
|
-
}
|
|
251
|
-
async function getProjectDb() {
|
|
252
|
-
const libDb = await import(`${cedarPaths.api.lib}/db`);
|
|
253
|
-
return libDb.db;
|
|
254
|
-
}
|
|
255
|
-
function isIdenticalArray(a, b) {
|
|
256
|
-
return JSON.stringify(a) === JSON.stringify(b);
|
|
257
|
-
}
|
|
258
|
-
function deepCopy(obj) {
|
|
259
|
-
return JSON.parse(JSON.stringify(obj));
|
|
260
|
-
}
|
|
261
|
-
function isErrorWithMessage(e) {
|
|
262
|
-
return !!e && typeof e === "object" && "message" in e && typeof e.message === "string";
|
|
263
|
-
}
|
|
264
|
-
function isErrorWithCode(e) {
|
|
265
|
-
return !!e && typeof e === "object" && "code" in e && typeof e.code === "string";
|
|
266
|
-
}
|
|
267
|
-
globalThis.scenario = buildScenario(import_vitest.it);
|
|
268
|
-
globalThis.scenario.only = buildScenario(import_vitest.it.only);
|
|
269
|
-
globalThis.describeScenario = buildDescribeScenario(import_vitest.describe);
|
|
270
|
-
globalThis.describeScenario.only = buildDescribeScenario(import_vitest.describe.only);
|
|
@@ -1,50 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,GAAI,OAAO,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,QAIxE,CAAA"}
|
package/dist/cjs/cache/index.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
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 === /* @__PURE__ */ 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
|
-
});
|
package/dist/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MockProviders.d.ts","sourceRoot":"","sources":["../../../src/web/MockProviders.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AA+BzB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAClD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAYA,CAAA"}
|
|
@@ -1,66 +0,0 @@
|
|
|
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_CedarApolloProvider = require("@cedarjs/web/apollo/CedarApolloProvider");
|
|
38
|
-
var import_globRoutesImporter = require("./globRoutesImporter.js");
|
|
39
|
-
var import_mockAuth = require("./mockAuth.js");
|
|
40
|
-
var import_MockParamsProvider = require("./MockParamsProvider.js");
|
|
41
|
-
let UserRoutes;
|
|
42
|
-
try {
|
|
43
|
-
const userRoutesModule = require("~__CEDAR__USER_ROUTES_FOR_MOCK");
|
|
44
|
-
UserRoutes = userRoutesModule.default;
|
|
45
|
-
} catch (error) {
|
|
46
|
-
if (!isModuleNotFoundError(error, "~__CEDAR__USER_ROUTES_FOR_MOCK")) {
|
|
47
|
-
console.warn(error);
|
|
48
|
-
}
|
|
49
|
-
UserRoutes = () => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null);
|
|
50
|
-
}
|
|
51
|
-
const MockProviders = ({ children }) => {
|
|
52
|
-
return /* @__PURE__ */ import_react.default.createElement(import_web.CedarProvider, { titleTemplate: "%PageTitle | %AppTitle" }, /* @__PURE__ */ import_react.default.createElement(import_CedarApolloProvider.CedarApolloProvider, { useAuth: import_mockAuth.useAuth }, /* @__PURE__ */ import_react.default.createElement(UserRoutes, null), /* @__PURE__ */ import_react.default.createElement(import_globRoutesImporter.UserRoutes, null), /* @__PURE__ */ import_react.default.createElement(import_router.LocationProvider, null, /* @__PURE__ */ import_react.default.createElement(import_MockParamsProvider.MockParamsProvider, null, children))));
|
|
53
|
-
};
|
|
54
|
-
function isModuleNotFoundError(error, module2) {
|
|
55
|
-
if (!error || typeof error !== "object" || !("code" in error) || error.code !== "MODULE_NOT_FOUND") {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
if ("moduleName" in error) {
|
|
59
|
-
return error.moduleName === module2;
|
|
60
|
-
}
|
|
61
|
-
return "message" in error && typeof error.message === "string" && (error.message.includes(`'${module2}'`) || error.message.includes(`"${module2}"`));
|
|
62
|
-
}
|
|
63
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
-
0 && (module.exports = {
|
|
65
|
-
MockProviders
|
|
66
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
* This router populates the `routes.<pageName>()` utility object.
|
|
9
|
-
*/
|
|
10
|
-
export declare const Router: React.FC<RouterProps>;
|
|
11
|
-
//# sourceMappingURL=MockRouter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MockRouter.d.ts","sourceRoot":"","sources":["../../../src/web/MockRouter.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAG9D,cAAc,4BAA4B,CAAA;AAE1C,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,MAAM,CAAA;CAAO,CAAA;AAE/D;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAcxC,CAAA"}
|
|
@@ -1,48 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,6 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,GACvB,IAAI,KAAK,CAAC,YAAY,EACtB,UAAS,aAAkB,KAC1B,YAKF,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,KAAK,EAAE,MAAM,EAC5C,QAAQ,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,EAChC,UAAU,uBAAuB,CAAC,KAAK,CAAC,KACvC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAKhC,CAAA"}
|