@carecard/auth-util 3.17.0 → 3.19.0

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.
@@ -0,0 +1,62 @@
1
+ import assert from 'node:assert/strict';
2
+ import { readdirSync, readFileSync } from 'node:fs';
3
+ import { createRequire } from 'node:module';
4
+ import { join, relative, resolve } from 'node:path';
5
+ import test from 'node:test';
6
+
7
+ const require = createRequire(import.meta.url);
8
+ const repositoryRoot = resolve(import.meta.dirname, '../..');
9
+ const packageJson = JSON.parse(
10
+ readFileSync(new URL('../../package.json', import.meta.url), 'utf8'),
11
+ );
12
+ const packageTaskRunnerSource = readFileSync(
13
+ new URL('../runPackageTask.mjs', import.meta.url),
14
+ 'utf8',
15
+ );
16
+ const testIndexSource = readFileSync(new URL('../../test/index.test.js', import.meta.url), 'utf8');
17
+ const { parallelTestFiles } = require('../../test/index.test.js');
18
+
19
+ function listRuntimeTestFiles(directoryPath) {
20
+ return readdirSync(directoryPath, { withFileTypes: true }).flatMap(entry => {
21
+ const entryPath = join(directoryPath, entry.name);
22
+ if (entry.isDirectory()) {
23
+ return listRuntimeTestFiles(entryPath);
24
+ }
25
+ if (!/\.test\.(?:js|mjs)$/.test(entry.name) || entry.name === 'index.test.js') {
26
+ return [];
27
+ }
28
+ return [relative(repositoryRoot, entryPath)];
29
+ });
30
+ }
31
+
32
+ test('keeps runtime test selection in the index and package scripts short', () => {
33
+ assert.equal(packageJson.scripts.test, 'node scripts/runPackageTask.mjs test');
34
+ assert.equal(
35
+ packageJson.scripts['test:coverage'],
36
+ 'node scripts/runPackageTask.mjs test:coverage',
37
+ );
38
+ assert.match(packageTaskRunnerSource, /arguments: \['run', 'test:order'\]/);
39
+ assert.match(packageTaskRunnerSource, /arguments: \['node', 'test\/index\.test\.js'\]/);
40
+ assert.match(packageTaskRunnerSource, /command: 'nyc'/);
41
+ assert.match(testIndexSource, /parallelTestFiles/);
42
+ assert.match(testIndexSource, /runIndexedMochaTests/);
43
+ assert.match(testIndexSource, /if \(require\.main === module\)/);
44
+ });
45
+
46
+ test('keeps parallel behavior tests in the test-order gate and static policy checks in the audit gate', () => {
47
+ assert.match(
48
+ packageJson.scripts['test:order'],
49
+ /scripts\/testParallel\/runIndexedMochaTests\.test\.mjs/,
50
+ );
51
+ assert.equal(
52
+ packageJson.scripts['validate:audits'],
53
+ 'node scripts/runPackageTask.mjs validate:audits',
54
+ );
55
+ });
56
+
57
+ test('selects every runtime test file exactly once', () => {
58
+ assert.deepEqual(
59
+ [...parallelTestFiles].sort(),
60
+ listRuntimeTestFiles(resolve(repositoryRoot, 'test')).sort(),
61
+ );
62
+ });
@@ -15,7 +15,9 @@ function resolveParallelJobCount(
15
15
  availableJobCount = availableParallelism(),
16
16
  ) {
17
17
  const requestedJobCount =
18
- configuredJobCount === undefined ? Math.min(availableJobCount, defaultMaximum) : Number.parseInt(configuredJobCount, 10);
18
+ configuredJobCount === undefined
19
+ ? Math.min(availableJobCount, defaultMaximum)
20
+ : Number.parseInt(configuredJobCount, 10);
19
21
 
20
22
  if (!Number.isInteger(requestedJobCount) || requestedJobCount < 1) {
21
23
  throw new Error('TEST_PARALLEL_JOBS must be a positive integer.');
@@ -12,10 +12,16 @@ test('uses bounded Mocha file workers without randomized default ordering', () =
12
12
  const argumentsList = buildMochaArguments(['test/example.test.js'], 2);
13
13
 
14
14
  assert.ok(argumentsList.includes('--parallel'));
15
- assert.deepEqual(argumentsList.slice(argumentsList.indexOf('--jobs'), argumentsList.indexOf('--jobs') + 2), ['--jobs', '2']);
15
+ assert.deepEqual(
16
+ argumentsList.slice(argumentsList.indexOf('--jobs'), argumentsList.indexOf('--jobs') + 2),
17
+ ['--jobs', '2'],
18
+ );
16
19
  assert.ok(argumentsList.includes('test/example.test.js'));
17
20
  });
18
21
 
19
22
  test('rejects invalid worker configuration instead of changing execution silently', () => {
20
- assert.throws(() => resolveParallelJobCount('0', 8, 4, 12), /TEST_PARALLEL_JOBS must be a positive integer/);
23
+ assert.throws(
24
+ () => resolveParallelJobCount('0', 8, 4, 12),
25
+ /TEST_PARALLEL_JOBS must be a positive integer/,
26
+ );
21
27
  });
@@ -1,39 +0,0 @@
1
- import assert from 'node:assert/strict';
2
- import { readdirSync, readFileSync } from 'node:fs';
3
- import { createRequire } from 'node:module';
4
- import { join, relative, resolve } from 'node:path';
5
- import test from 'node:test';
6
-
7
- const require = createRequire(import.meta.url);
8
- const repositoryRoot = resolve(import.meta.dirname, '../..');
9
- const packageJson = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
10
- const testIndexSource = readFileSync(new URL('../../test/index.test.js', import.meta.url), 'utf8');
11
- const { parallelTestFiles } = require('../../test/index.test.js');
12
-
13
- function listRuntimeTestFiles(directoryPath) {
14
- return readdirSync(directoryPath, { withFileTypes: true }).flatMap(entry => {
15
- const entryPath = join(directoryPath, entry.name);
16
- if (entry.isDirectory()) return listRuntimeTestFiles(entryPath);
17
- if (!/\.test\.(?:js|mjs)$/.test(entry.name) || entry.name === 'index.test.js') {
18
- return [];
19
- }
20
- return [relative(repositoryRoot, entryPath)];
21
- });
22
- }
23
-
24
- test('keeps runtime test selection in the index and package scripts short', () => {
25
- assert.equal(packageJson.scripts.test, 'npm run test:order && node test/index.test.js');
26
- assert.match(packageJson.scripts['test:coverage'], /nyc node test\/index\.test\.js$/);
27
- assert.match(testIndexSource, /parallelTestFiles/);
28
- assert.match(testIndexSource, /runIndexedMochaTests/);
29
- assert.match(testIndexSource, /if \(require\.main === module\)/);
30
- });
31
-
32
- test('runs the parallel execution contract in the test-order gate', () => {
33
- assert.match(packageJson.scripts['test:order'], /scripts\/testParallel\/parallelTestPolicy\.test\.mjs/);
34
- assert.match(packageJson.scripts['test:order'], /scripts\/testParallel\/runIndexedMochaTests\.test\.mjs/);
35
- });
36
-
37
- test('selects every runtime test file exactly once', () => {
38
- assert.deepEqual([...parallelTestFiles].sort(), listRuntimeTestFiles(resolve(repositoryRoot, 'test')).sort());
39
- });