refactoring of es6 test skeleton

This commit is contained in:
zadam
2020-06-03 17:28:57 +02:00
parent 99120be46d
commit 01a7af965c
4 changed files with 21 additions and 95 deletions

View File

@@ -0,0 +1,10 @@
import attributeParser from '../src/public/app/services/attribute_parser.js';
import {describe, it, expect, execute} from './mini_test.js';
describe("Lexer fulltext", () => {
it("simple label", () => {
expect(attributeParser.lexer("#label")).toEqual(["#label"]);
});
});
execute();

View File

@@ -1,12 +1,10 @@
import attributeParser from '../src/public/app/services/attribute_parser.mjs';
function describe(name, cb) {
export function describe(name, cb) {
console.log(`Running ${name}`);
cb();
}
function it(name, cb) {
export async function it(name, cb) {
console.log(` Running ${name}`);
cb();
@@ -14,7 +12,7 @@ function it(name, cb) {
let errorCount = 0;
function expect(val) {
export function expect(val) {
return {
toEqual: comparedVal => {
const jsonVal = JSON.stringify(val);
@@ -31,17 +29,13 @@ function expect(val) {
}
}
describe("Lexer fulltext", () => {
it("simple label", () => {
expect(attributeParser.lexer("#label")).toEqual(["#labe"]);
});
});
export function execute() {
console.log("");
console.log("");
if (errorCount) {
console.log(`!!!${errorCount} tests failed!!!`);
}
else {
console.log("All tests passed!");
if (errorCount) {
console.log(`!!!${errorCount} tests failed!!!`);
}
else {
console.log("All tests passed!");
}
}