-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix - parse args with equal sign (#50)
* Refactor parseArgs to allow usage of '-k=value' style args * Improve maxIterations validation * Create tests for Utils and add parseArgs and argsAreValid tests * Update dependencies * 1.4.6
- Loading branch information
1 parent
7286817
commit 08b557b
Showing
6 changed files
with
339 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const assert = require('node:assert'); | ||
|
||
const tests = { | ||
Utils: __dirname + '/utils-tests', | ||
}; | ||
|
||
/** | ||
* Generic function for verifying a utility function is behaving as expected. | ||
* @param testName {string} - The name of the test to be displayed | ||
* @param testFunc {function} - The source code to be used | ||
* @param verifyFunc {function} - The expected output | ||
*/ | ||
function testCodeSample(testName, testFunc, verifyFunc) { | ||
process.stdout.write(`Testing ${testName}... `); | ||
console.time('PASS'); | ||
const results = testFunc(); | ||
const expected = verifyFunc(); | ||
assert.deepEqual(results, expected); | ||
console.timeEnd('PASS'); | ||
} | ||
|
||
let allTests = 0; | ||
let skippedTests = 0; | ||
console.time('tests in'); | ||
for (const [moduleName, moduleTests] of Object.entries(tests)) { | ||
const loadedTests = require(moduleTests); | ||
for (const test of loadedTests) { | ||
allTests++; | ||
if (test.enabled) { | ||
testCodeSample(`[${moduleName}] ${test.name}`.padEnd(90, '.'), test.testFunc, test.verifyFunc); | ||
} else { | ||
skippedTests++; | ||
console.log(`Testing [${moduleName}] ${test.name}...`.padEnd(101, '.') + ` SKIPPED: ${test.reason}`); | ||
} | ||
} | ||
} | ||
if (skippedTests > 0) { | ||
process.stdout.write(`Completed ${allTests - skippedTests}/${allTests} (${skippedTests} skipped) utility `); | ||
} else process.stdout.write(`Completed ${allTests} utility `); | ||
console.timeEnd('tests in'); |
Oops, something went wrong.