adding prettier

This commit is contained in:
Hare Sudhan 2024-02-25 16:31:23 -05:00
parent c5a1b69c30
commit ab0bc52d3c
717 changed files with 29324 additions and 18602 deletions

View file

@ -21,7 +21,6 @@ import log from "loglevel";
* @constructor
*/
class TestRegister {
/**
* initialise with no tests
*/
@ -50,14 +49,17 @@ class TestRegister {
/**
* Runs all the tests in the register.
*/
async runTests () {
async runTests() {
// Turn off logging to avoid messy errors
log.setLevel("silent", false);
const progBar = new cliProgress.SingleBar({
format: formatter,
stopOnComplete: true
}, cliProgress.Presets.shades_classic);
const progBar = new cliProgress.SingleBar(
{
format: formatter,
stopOnComplete: true
},
cliProgress.Presets.shades_classic
);
const testResults = [];
console.log("Running operation tests...");
@ -71,11 +73,7 @@ class TestRegister {
});
const chef = new Chef();
const result = await chef.bake(
test.input,
test.recipeConfig,
{ returnType: "string" }
);
const result = await chef.bake(test.input, test.recipeConfig, { returnType: "string" });
const ret = {
test: test,
@ -94,7 +92,7 @@ class TestRegister {
"Expected",
"\t" + test.expectedOutput.replace(/\n/g, "\n\t"),
"Received",
"\t" + result.error.displayStr.replace(/\n/g, "\n\t"),
"\t" + result.error.displayStr.replace(/\n/g, "\n\t")
].join("\n");
}
} else {
@ -113,15 +111,18 @@ class TestRegister {
ret.status = "passing";
} else {
ret.status = "failing";
const expected = test.expectedOutput ? test.expectedOutput :
test.expectedMatch ? test.expectedMatch.toString() :
test.unexpectedMatch ? "to not find " + test.unexpectedMatch.toString() :
"unknown";
const expected = test.expectedOutput
? test.expectedOutput
: test.expectedMatch
? test.expectedMatch.toString()
: test.unexpectedMatch
? "to not find " + test.unexpectedMatch.toString()
: "unknown";
ret.output = [
"Expected",
"\t" + expected.replace(/\n/g, "\n\t"),
"Received",
"\t" + result.result.replace(/\n/g, "\n\t"),
"\t" + result.result.replace(/\n/g, "\n\t")
].join("\n");
}
}
@ -140,10 +141,13 @@ class TestRegister {
* Run all api related tests and wrap results in report format
*/
async runApiTests() {
const progBar = new cliProgress.SingleBar({
format: formatter,
stopOnComplete: true
}, cliProgress.Presets.shades_classic);
const progBar = new cliProgress.SingleBar(
{
format: formatter,
stopOnComplete: true
},
cliProgress.Presets.shades_classic
);
const testResults = [];
console.log("Running Node API tests...");
@ -178,7 +182,6 @@ class TestRegister {
}
}
/**
* Formatter for the progress bar
*
@ -188,8 +191,9 @@ class TestRegister {
* @returns {string}
*/
function formatter(options, params, payload) {
const bar = options.barCompleteString.substr(0, Math.round(params.progress * options.barsize)) +
options.barIncompleteString.substr(0, Math.round((1-params.progress) * options.barsize));
const bar
= options.barCompleteString.substr(0, Math.round(params.progress * options.barsize))
+ options.barIncompleteString.substr(0, Math.round((1 - params.progress) * options.barsize));
const percentage = Math.floor(params.progress * 100),
duration = Math.floor((Date.now() - params.startTime) / 1000);