tests: create TestRunner
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
{
|
||||
runLog.length = 0;
|
||||
tests.register("Maximization", 100, () => {
|
||||
const workspaceMock = initMocks();
|
||||
const config = getDefaultConfig();
|
||||
const world = new World(config);
|
||||
@@ -34,4 +33,4 @@
|
||||
|
||||
kwinClient.setMaximize(false, false);
|
||||
assertRect(kwinClient.frameGeometry, columnLeftX, columnTopY, 300, columnHeight);
|
||||
}
|
||||
});
|
||||
|
||||
1
src/tests/main.ts
Normal file
1
src/tests/main.ts
Normal file
@@ -0,0 +1 @@
|
||||
tests.run();
|
||||
@@ -4,6 +4,7 @@
|
||||
"../lib/**/*",
|
||||
"./utils/**/*",
|
||||
"./units/**/*",
|
||||
"./flows/**/*"
|
||||
"./flows/**/*",
|
||||
"./main.ts"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
tests.register("WindowRuleEnforcer", 1, () => {
|
||||
const testCases = [
|
||||
{tiledByDefault: true, resourceClass: "unknown", caption: "anything", shouldTile: true},
|
||||
{tiledByDefault: false, resourceClass: "unknown", caption: "anything", shouldTile: false},
|
||||
@@ -33,4 +33,4 @@
|
||||
caption: caption,
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
28
src/tests/utils/TestRunner.ts
Normal file
28
src/tests/utils/TestRunner.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
class TestRunner {
|
||||
private readonly tests: TestRunner.Test[] = [];
|
||||
|
||||
public register(name: string, count: number, f: () => void) {
|
||||
this.tests.push({ name: name, count: count, f: f });
|
||||
}
|
||||
|
||||
public run() {
|
||||
for (const test of this.tests) {
|
||||
console.log("Running test " + test.name);
|
||||
for (let i = 0; i < test.count; i++) {
|
||||
runLog.length = 0;
|
||||
test.f();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace TestRunner {
|
||||
export type Test = {
|
||||
name: string,
|
||||
count: number,
|
||||
f: () => void,
|
||||
}
|
||||
}
|
||||
|
||||
const runLog: string[] = [];
|
||||
const tests = new TestRunner();
|
||||
@@ -1,5 +1,3 @@
|
||||
const runLog: string[] = [];
|
||||
|
||||
function assert(assertion: boolean, message?: string, skip: number = 0) {
|
||||
if (assertion) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user