@carbonorm/carbonreact 3.3.1 → 3.3.3

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/index.esm.js CHANGED
@@ -4251,33 +4251,33 @@ function validSQL$1 (sql) {
4251
4251
  validSQL.push({ [expect.getState().currentTestName.replaceAll(" ", "_").toLowerCase()]: sql });
4252
4252
  }
4253
4253
 
4254
- function setupTests () {
4255
- const origionalWindowLocation = window.location;
4254
+ function setupTests ({ sqlDirectory = './logs/rest/', logsDirectory = './logs/tests/' } = {}) {
4255
+ const originalWindowLocation = window.location;
4256
4256
  const testName = () => expect.getState().currentTestName?.replaceAll(" ", "_").toLowerCase();
4257
- const validSqlFile = () => './logs/rest/' + testName() + '.json';
4258
- const logsFile = () => './logs/tests/' + testName() + '.log';
4257
+ const validSqlFile = () => sqlDirectory + testName() + '.json';
4258
+ const logsFile = () => logsDirectory + testName() + '.log';
4259
4259
  /* eslint-disable no-undef */
4260
4260
  expect(document).not.toBeNull();
4261
4261
  const orig = console;
4262
4262
  // @link https://stackoverflow.com/questions/13542667/create-directory-when-writing-to-file-in-node-js
4263
- const superLogger = async (...args) => fs.writeFileSync(logsFile(), '\n' + inspect(args.length === 1 ? args.pop() : args, false, 10, true), { flag: "a+" });
4263
+ const asyncFileLogging = async (...args) => fs.writeFileSync(logsFile(), '\n' + inspect(args.length === 1 ? args.pop() : args, false, 10, true), { flag: "a+" });
4264
4264
  // noinspection CommaExpressionJS
4265
4265
  global.console = {
4266
4266
  ...console,
4267
4267
  // use jest.fn() to silence, comment out to leave as it is
4268
- log: (...args) => (isVerbose && orig.log(...args), superLogger('log', ...args)),
4269
- error: (...args) => (isVerbose && orig.error(...args), superLogger('error', ...args)),
4270
- warn: (...args) => (isVerbose && orig.warn(...args), superLogger('warn', ...args)),
4271
- info: (...args) => (isVerbose && orig.info(...args), superLogger('info', ...args)),
4272
- debug: (...args) => (isVerbose && orig.debug(...args), superLogger('debug', ...args)),
4273
- table: (...args) => (isVerbose && orig.table(...args), superLogger('table', ...args)),
4274
- trace: (...args) => (isVerbose && orig.trace(...args), superLogger((() => {
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
4275
  const err = new Error();
4276
4276
  return err.stack;
4277
4277
  })())),
4278
- group: (...args) => (isVerbose && orig.group(...args), superLogger('group', ...args)),
4279
- groupCollapsed: (...args) => (isVerbose && orig.groupCollapsed(args), superLogger('groupCollapsed', ...args)),
4280
- groupEnd: () => (isVerbose && orig.groupEnd(), superLogger('groupEnd')),
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
4281
  };
4282
4282
  afterEach(async () => {
4283
4283
  await waitFor(async () => {
@@ -4288,7 +4288,7 @@ function setupTests () {
4288
4288
  console.log('After each Test (' + expect.getState().currentTestName + ')', expect.getState());
4289
4289
  // restore `window.location` to the original `jsdom`
4290
4290
  // `Location` object
4291
- window.location = origionalWindowLocation;
4291
+ window.location = originalWindowLocation;
4292
4292
  fs.writeFileSync(validSqlFile(), JSON.stringify(validSQL, undefined, 2) ?? '');
4293
4293
  }, 65000);
4294
4294
  }