@carbonorm/carbonreact 3.3.0 → 3.3.2
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/dist/hoc/setupTests.d.ts +4 -1
- package/dist/index.cjs.js +42 -39
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +42 -40
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/hoc/setupTests.tsx +45 -42
- package/src/hoc/validSQL.tsx +2 -1
- package/src/index.ts +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export { default as setCookies } from "./hoc/setCookies";
|
|
|
40
40
|
export * from "./hoc/setCookies";
|
|
41
41
|
export { default as setUrl } from "./hoc/setUrl";
|
|
42
42
|
export * from "./hoc/setUrl";
|
|
43
|
+
export { default as setupTests } from "./hoc/setupTests";
|
|
43
44
|
export * from "./hoc/setupTests";
|
|
44
45
|
export { default as updateRestfulObjectArrays } from "./hoc/updateRestfulObjectArrays";
|
|
45
46
|
export * from "./hoc/updateRestfulObjectArrays";
|
package/dist/index.esm.js
CHANGED
|
@@ -4251,45 +4251,47 @@ function validSQL$1 (sql) {
|
|
|
4251
4251
|
validSQL.push({ [expect.getState().currentTestName.replaceAll(" ", "_").toLowerCase()]: sql });
|
|
4252
4252
|
}
|
|
4253
4253
|
|
|
4254
|
-
|
|
4255
|
-
const
|
|
4256
|
-
const
|
|
4257
|
-
const
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4254
|
+
function setupTests ({ sqlDirectory = './logs/rest/', logsDirectory = './logs/tests/' }) {
|
|
4255
|
+
const originalWindowLocation = window.location;
|
|
4256
|
+
const testName = () => expect.getState().currentTestName?.replaceAll(" ", "_").toLowerCase();
|
|
4257
|
+
const validSqlFile = () => sqlDirectory + testName() + '.json';
|
|
4258
|
+
const logsFile = () => logsDirectory + testName() + '.log';
|
|
4259
|
+
/* eslint-disable no-undef */
|
|
4260
|
+
expect(document).not.toBeNull();
|
|
4261
|
+
const orig = console;
|
|
4262
|
+
// @link https://stackoverflow.com/questions/13542667/create-directory-when-writing-to-file-in-node-js
|
|
4263
|
+
const asyncFileLogging = async (...args) => fs.writeFileSync(logsFile(), '\n' + inspect(args.length === 1 ? args.pop() : args, false, 10, true), { flag: "a+" });
|
|
4264
|
+
// noinspection CommaExpressionJS
|
|
4265
|
+
global.console = {
|
|
4266
|
+
...console,
|
|
4267
|
+
// use jest.fn() to silence, comment out to leave as it is
|
|
4268
|
+
log: (...args) => (isVerbose && orig.log(...args), asyncFileLogging('log', ...args)),
|
|
4269
|
+
error: (...args) => (isVerbose && orig.error(...args), asyncFileLogging('error', ...args)),
|
|
4270
|
+
warn: (...args) => (isVerbose && orig.warn(...args), asyncFileLogging('warn', ...args)),
|
|
4271
|
+
info: (...args) => (isVerbose && orig.info(...args), asyncFileLogging('info', ...args)),
|
|
4272
|
+
debug: (...args) => (isVerbose && orig.debug(...args), asyncFileLogging('debug', ...args)),
|
|
4273
|
+
table: (...args) => (isVerbose && orig.table(...args), asyncFileLogging('table', ...args)),
|
|
4274
|
+
trace: (...args) => (isVerbose && orig.trace(...args), asyncFileLogging((() => {
|
|
4275
|
+
const err = new Error();
|
|
4276
|
+
return err.stack;
|
|
4277
|
+
})())),
|
|
4278
|
+
group: (...args) => (isVerbose && orig.group(...args), asyncFileLogging('group', ...args)),
|
|
4279
|
+
groupCollapsed: (...args) => (isVerbose && orig.groupCollapsed(args), asyncFileLogging('groupCollapsed', ...args)),
|
|
4280
|
+
groupEnd: () => (isVerbose && orig.groupEnd(), asyncFileLogging('groupEnd')),
|
|
4281
|
+
};
|
|
4282
|
+
afterEach(async () => {
|
|
4283
|
+
await waitFor(async () => {
|
|
4284
|
+
expect(checkAllRequestsComplete()).toEqual(true);
|
|
4285
|
+
}, { timeout: 3000, interval: 1000 });
|
|
4286
|
+
// this must be a dynamic import to avoid loading dependencies out of order
|
|
4287
|
+
// await waitForTrailingRequests({testPassed: true, timeout: 12000})
|
|
4288
|
+
console.log('After each Test (' + expect.getState().currentTestName + ')', expect.getState());
|
|
4289
|
+
// restore `window.location` to the original `jsdom`
|
|
4290
|
+
// `Location` object
|
|
4291
|
+
window.location = originalWindowLocation;
|
|
4292
|
+
fs.writeFileSync(validSqlFile(), JSON.stringify(validSQL, undefined, 2) ?? '');
|
|
4293
|
+
}, 65000);
|
|
4294
|
+
}
|
|
4293
4295
|
|
|
4294
4296
|
var eUpdateInsertMethod;
|
|
4295
4297
|
(function (eUpdateInsertMethod) {
|
|
@@ -4472,5 +4474,5 @@ function useWindowDimensions() {
|
|
|
4472
4474
|
return windowDimensions;
|
|
4473
4475
|
}
|
|
4474
4476
|
|
|
4475
|
-
export { AccessDenied, Alert, BackendThrowable, C6, COLUMNS, CarbonReact, ErrorHttpCode, GlobalHistory, Loading, Nest, PageNotFound, Popup, TABLES, addAlert, addValidSQL$1 as addValidSQL, carbons, changed, comments, deleteRestfulObjectArrays, documentation, eUpdateInsertMethod, feature_group_references, features, getRootStyleValue, getStyles, globalNavigate, group_references, groups, hexToRgb, history_logs, initialCarbonReactState, initialRequiredCarbonORMState, initialRestfulObjectsState, isEdgeBrowser, isProduction, location_references, locations, parseMultipleJson, photos, range, reports, ScrollIntoViewDirective as scrollIntoView, setCookies, setUrl, toDataURL, updateRestfulObjectArrays, uploadImage, uploadImageChange, user_followers, user_groups, user_messages, user_sessions, user_tasks, users, validSQL$1 as validSQL, useWindowDimensions as windowDimensions, wp_commentmeta, wp_comments, wp_links, wp_options, wp_postmeta, wp_posts, wp_term_relationships, wp_term_taxonomy, wp_termmeta, wp_terms, wp_usermeta, wp_users };
|
|
4477
|
+
export { AccessDenied, Alert, BackendThrowable, C6, COLUMNS, CarbonReact, ErrorHttpCode, GlobalHistory, Loading, Nest, PageNotFound, Popup, TABLES, addAlert, addValidSQL$1 as addValidSQL, carbons, changed, comments, deleteRestfulObjectArrays, documentation, eUpdateInsertMethod, feature_group_references, features, getRootStyleValue, getStyles, globalNavigate, group_references, groups, hexToRgb, history_logs, initialCarbonReactState, initialRequiredCarbonORMState, initialRestfulObjectsState, isEdgeBrowser, isProduction, location_references, locations, parseMultipleJson, photos, range, reports, ScrollIntoViewDirective as scrollIntoView, setCookies, setUrl, setupTests, toDataURL, updateRestfulObjectArrays, uploadImage, uploadImageChange, user_followers, user_groups, user_messages, user_sessions, user_tasks, users, validSQL$1 as validSQL, useWindowDimensions as windowDimensions, wp_commentmeta, wp_comments, wp_links, wp_options, wp_postmeta, wp_posts, wp_term_relationships, wp_term_taxonomy, wp_termmeta, wp_terms, wp_usermeta, wp_users };
|
|
4476
4478
|
//# sourceMappingURL=index.esm.js.map
|