mirror of
https://github.com/zadam/trilium.git
synced 2025-10-30 18:05:55 +01:00
refactoring of es6 test skeleton
This commit is contained in:
41
spec-es6/mini_test.js
Normal file
41
spec-es6/mini_test.js
Normal file
@@ -0,0 +1,41 @@
|
||||
export function describe(name, cb) {
|
||||
console.log(`Running ${name}`);
|
||||
|
||||
cb();
|
||||
}
|
||||
|
||||
export async function it(name, cb) {
|
||||
console.log(` Running ${name}`);
|
||||
|
||||
cb();
|
||||
}
|
||||
|
||||
let errorCount = 0;
|
||||
|
||||
export function expect(val) {
|
||||
return {
|
||||
toEqual: comparedVal => {
|
||||
const jsonVal = JSON.stringify(val);
|
||||
const comparedJsonVal = JSON.stringify(comparedVal);
|
||||
|
||||
if (jsonVal !== comparedJsonVal) {
|
||||
console.trace("toEqual check failed.");
|
||||
console.error(`expected: ${comparedJsonVal}`);
|
||||
console.error(`got: ${jsonVal}`);
|
||||
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function execute() {
|
||||
console.log("");
|
||||
|
||||
if (errorCount) {
|
||||
console.log(`!!!${errorCount} tests failed!!!`);
|
||||
}
|
||||
else {
|
||||
console.log("All tests passed!");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user