@davidsouther/jiffies 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/assert.d.ts +23 -23
- package/build/assert.js +33 -33
- package/build/case.d.ts +1 -1
- package/build/case.js +5 -5
- package/build/components/button_bar.d.ts +8 -8
- package/build/components/button_bar.js +27 -27
- package/build/components/inline_edit.d.ts +12 -12
- package/build/components/inline_edit.js +48 -48
- package/build/components/logger.d.ts +6 -7
- package/build/components/logger.js +22 -22
- package/build/components/select.d.ts +13 -10
- package/build/components/select.js +3 -3
- package/build/components/test.d.ts +1 -1
- package/build/components/test.js +2 -2
- package/build/components/virtual_scroll.d.ts +40 -41
- package/build/components/virtual_scroll.js +94 -94
- package/build/components/virtual_scroll.test.d.ts +1 -1
- package/build/components/virtual_scroll.test.js +21 -21
- package/build/context.d.ts +15 -15
- package/build/context.js +43 -43
- package/build/context.test.d.ts +1 -1
- package/build/context.test.js +46 -46
- package/build/debounce.d.ts +1 -1
- package/build/debounce.js +7 -7
- package/build/display.d.ts +5 -5
- package/build/display.js +11 -11
- package/build/dom/css/border.d.ts +11 -11
- package/build/dom/css/border.js +27 -27
- package/build/dom/css/constants.d.ts +31 -31
- package/build/dom/css/constants.js +28 -28
- package/build/dom/css/core.d.ts +5 -5
- package/build/dom/css/core.js +24 -24
- package/build/dom/css/fstyle.d.ts +5 -5
- package/build/dom/css/fstyle.js +32 -32
- package/build/dom/css/sizing.d.ts +5 -5
- package/build/dom/css/sizing.js +10 -10
- package/build/dom/dom.d.ts +26 -27
- package/build/dom/dom.js +95 -95
- package/build/dom/fc.d.ts +14 -14
- package/build/dom/fc.js +36 -35
- package/build/dom/fc.test.d.ts +1 -1
- package/build/dom/fc.test.js +21 -21
- package/build/dom/form/form.app.d.ts +1 -1
- package/build/dom/form/form.app.js +23 -23
- package/build/dom/form/form.d.ts +26 -26
- package/build/dom/form/form.js +34 -34
- package/build/dom/form/form.test.js +1 -1
- package/build/dom/html.d.ts +113 -117
- package/build/dom/html.js +114 -114
- package/build/dom/html.test.d.ts +1 -1
- package/build/dom/html.test.js +58 -58
- package/build/dom/provide.d.ts +3 -3
- package/build/dom/provide.js +7 -7
- package/build/dom/router/link.d.ts +6 -6
- package/build/dom/router/link.js +3 -3
- package/build/dom/router/router.d.ts +12 -12
- package/build/dom/router/router.js +49 -49
- package/build/dom/svg.d.ts +64 -64
- package/build/dom/svg.js +65 -65
- package/build/dom/test.d.ts +1 -1
- package/build/dom/test.js +2 -2
- package/build/dom/types/css.d.ts +6612 -6612
- package/build/dom/types/css.js +23 -23
- package/build/dom/types/dom.js +1 -1
- package/build/dom/types/html.d.ts +616 -616
- package/build/dom/types/html.js +1 -1
- package/build/dom/xml.d.ts +1 -1
- package/build/dom/xml.js +4 -5
- package/build/equal.d.ts +5 -5
- package/build/equal.js +37 -37
- package/build/equal.test.d.ts +1 -1
- package/build/equal.test.js +20 -20
- package/build/flags.d.ts +7 -7
- package/build/flags.js +48 -48
- package/build/flags.test.d.ts +1 -1
- package/build/flags.test.js +35 -35
- package/build/fs.d.ts +48 -48
- package/build/fs.js +144 -144
- package/build/fs.test.d.ts +1 -1
- package/build/fs.test.js +43 -43
- package/build/generator.d.ts +1 -1
- package/build/generator.js +10 -10
- package/build/generator.test.d.ts +1 -1
- package/build/generator.test.js +24 -24
- package/build/is_browser.d.ts +1 -1
- package/build/is_browser.js +1 -1
- package/build/loader.d.mts +22 -22
- package/build/loader.mjs +35 -35
- package/build/lock.d.ts +1 -1
- package/build/lock.js +23 -23
- package/build/lock.test.d.ts +1 -1
- package/build/lock.test.js +16 -16
- package/build/log.d.ts +26 -26
- package/build/log.js +46 -46
- package/build/observable/observable.d.ts +83 -0
- package/build/observable/observable.js +148 -0
- package/build/observable/observable.test.d.ts +1 -0
- package/build/observable/observable.test.js +21 -0
- package/build/range.d.ts +1 -1
- package/build/range.js +7 -7
- package/build/result.d.ts +31 -31
- package/build/result.js +65 -65
- package/build/result.test.d.ts +1 -1
- package/build/result.test.js +71 -71
- package/build/safe.d.ts +1 -1
- package/build/safe.js +10 -10
- package/build/scope/describe.d.ts +18 -14
- package/build/scope/describe.js +61 -52
- package/build/scope/display/console.d.ts +2 -2
- package/build/scope/display/console.js +21 -21
- package/build/scope/display/dom.d.ts +3 -3
- package/build/scope/display/dom.js +26 -26
- package/build/scope/display/junit.d.ts +2 -2
- package/build/scope/display/junit.js +17 -17
- package/build/scope/execute.d.ts +12 -12
- package/build/scope/execute.js +85 -85
- package/build/scope/expect.d.ts +23 -23
- package/build/scope/expect.js +108 -108
- package/build/scope/fix.d.ts +4 -4
- package/build/scope/fix.js +22 -22
- package/build/scope/index.d.ts +3 -3
- package/build/scope/index.js +3 -3
- package/build/scope/scope.d.ts +17 -17
- package/build/scope/scope.js +1 -1
- package/build/server/http/apps.d.ts +5 -5
- package/build/server/http/apps.js +23 -23
- package/build/server/http/css.d.ts +5 -5
- package/build/server/http/css.js +50 -47
- package/build/server/http/index.d.ts +21 -21
- package/build/server/http/index.js +73 -73
- package/build/server/http/response.d.ts +4 -4
- package/build/server/http/response.js +40 -40
- package/build/server/http/sitemap.d.ts +2 -2
- package/build/server/http/sitemap.js +42 -42
- package/build/server/http/static.d.ts +2 -2
- package/build/server/http/static.js +21 -21
- package/build/server/http/typescript.d.ts +5 -5
- package/build/server/http/typescript.js +40 -40
- package/build/server/main.d.ts +2 -2
- package/build/server/main.js +9 -9
- package/build/test.d.mts +2 -2
- package/build/test.mjs +23 -23
- package/build/test_all.d.ts +7 -7
- package/build/test_all.js +18 -18
- package/build/transpile.d.mts +3 -3
- package/build/transpile.mjs +18 -18
- package/package.json +3 -3
- package/src/components/logger.ts +2 -3
- package/src/components/virtual_scroll.test.ts +4 -4
- package/src/components/virtual_scroll.ts +8 -8
- package/src/diff.test.ts +48 -0
- package/src/diff.ts +84 -0
- package/src/dom/dom.ts +73 -61
- package/src/dom/fc.ts +10 -9
- package/src/dom/html.test.ts +5 -5
- package/src/dom/html.ts +7 -10
- package/src/dom/observable.test.ts +43 -0
- package/src/dom/observable.ts +11 -0
- package/src/dom/router/router.ts +4 -4
- package/src/dom/test.ts +5 -1
- package/src/dom/xml.ts +1 -2
- package/src/index.html +6 -3
- package/src/observable/_notes +21 -8
- package/src/observable/event.ts +93 -0
- package/src/observable/observable.test.ts +73 -0
- package/src/observable/observable.ts +403 -0
- package/src/scope/describe.ts +14 -1
- package/src/scope/display/dom.ts +2 -2
- package/src/scope/execute.ts +2 -5
- package/src/server/http/css.ts +3 -1
- package/src/test_all.ts +10 -8
- package/src/observable/observable._js +0 -175
package/build/result.test.js
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import { Err, None, Ok, Some, unwrap, unwrapOr, unwrapOrElse, } from "./result.js";
|
|
2
|
-
import { describe, it } from "./scope/describe.js";
|
|
3
|
-
import { expect } from "./scope/expect.js";
|
|
4
|
-
describe("Result", () => {
|
|
5
|
-
it("converts Nones", () => {
|
|
6
|
-
const a = None();
|
|
7
|
-
expect(a).toBeNull();
|
|
8
|
-
const b = None();
|
|
9
|
-
expect(b).toBeNull();
|
|
10
|
-
const c = Some(a);
|
|
11
|
-
expect(c).toBeNull();
|
|
12
|
-
const d = Some(b);
|
|
13
|
-
expect(d).toBeNull();
|
|
14
|
-
});
|
|
15
|
-
it("converts Somes", () => {
|
|
16
|
-
const a = Some("a");
|
|
17
|
-
expect(a).toBe("a");
|
|
18
|
-
const b = Some(a);
|
|
19
|
-
expect(b).toBe("a");
|
|
20
|
-
});
|
|
21
|
-
it("converts Errs", () => {
|
|
22
|
-
const a = Err(new Error("a error"));
|
|
23
|
-
const b = Err(a);
|
|
24
|
-
expect(b).toMatchObject({ message: "a error" });
|
|
25
|
-
// Assign Err to Result
|
|
26
|
-
const c = a;
|
|
27
|
-
});
|
|
28
|
-
it("converts Oks", () => {
|
|
29
|
-
const a = Ok("a ok");
|
|
30
|
-
const b = Ok(a);
|
|
31
|
-
expect(b).toBe("a ok");
|
|
32
|
-
// Assign ok to Result
|
|
33
|
-
const c = a;
|
|
34
|
-
});
|
|
35
|
-
it("unwraps", () => {
|
|
36
|
-
const a = Some("some");
|
|
37
|
-
const b = None();
|
|
38
|
-
const c = Ok("ok");
|
|
39
|
-
const d = Err(new Error("err"));
|
|
40
|
-
const e = "else";
|
|
41
|
-
expect(unwrap(a)).toBe("some");
|
|
42
|
-
expect(unwrap(c)).toBe("ok");
|
|
43
|
-
expect(() => unwrap(b)).toThrow("Attempted to unwrap None");
|
|
44
|
-
expect(() => unwrap(d)).toThrow("err");
|
|
45
|
-
expect(unwrap(e)).toBe("else");
|
|
46
|
-
});
|
|
47
|
-
it("unwrapsOrs", () => {
|
|
48
|
-
const a = Some("some");
|
|
49
|
-
const b = None();
|
|
50
|
-
const c = Ok("ok");
|
|
51
|
-
const d = Err(new Error("err"));
|
|
52
|
-
const e = "else";
|
|
53
|
-
expect(unwrapOr(a, "z")).toBe("some");
|
|
54
|
-
expect(unwrapOr(c, "z")).toBe("ok");
|
|
55
|
-
expect(unwrapOr(b, "z")).toBe("z");
|
|
56
|
-
expect(unwrapOr(d, "z")).toBe("z");
|
|
57
|
-
expect(unwrapOr(e, "z")).toBe("else");
|
|
58
|
-
});
|
|
59
|
-
it("unwrapsOrElse", () => {
|
|
60
|
-
const a = Some("some");
|
|
61
|
-
const b = None();
|
|
62
|
-
const c = Ok("ok");
|
|
63
|
-
const d = Err(new Error("err"));
|
|
64
|
-
const e = "else";
|
|
65
|
-
expect(unwrapOrElse(a, () => "z")).toBe("some");
|
|
66
|
-
expect(unwrapOrElse(c, () => "z")).toBe("ok");
|
|
67
|
-
expect(unwrapOrElse(b, () => "z")).toBe("z");
|
|
68
|
-
expect(unwrapOrElse(d, () => "z")).toBe("z");
|
|
69
|
-
expect(unwrapOrElse(e, () => "z")).toBe("else");
|
|
70
|
-
});
|
|
71
|
-
});
|
|
1
|
+
import { Err, None, Ok, Some, unwrap, unwrapOr, unwrapOrElse, } from "./result.js";
|
|
2
|
+
import { describe, it } from "./scope/describe.js";
|
|
3
|
+
import { expect } from "./scope/expect.js";
|
|
4
|
+
describe("Result", () => {
|
|
5
|
+
it("converts Nones", () => {
|
|
6
|
+
const a = None();
|
|
7
|
+
expect(a).toBeNull();
|
|
8
|
+
const b = None();
|
|
9
|
+
expect(b).toBeNull();
|
|
10
|
+
const c = Some(a);
|
|
11
|
+
expect(c).toBeNull();
|
|
12
|
+
const d = Some(b);
|
|
13
|
+
expect(d).toBeNull();
|
|
14
|
+
});
|
|
15
|
+
it("converts Somes", () => {
|
|
16
|
+
const a = Some("a");
|
|
17
|
+
expect(a).toBe("a");
|
|
18
|
+
const b = Some(a);
|
|
19
|
+
expect(b).toBe("a");
|
|
20
|
+
});
|
|
21
|
+
it("converts Errs", () => {
|
|
22
|
+
const a = Err(new Error("a error"));
|
|
23
|
+
const b = Err(a);
|
|
24
|
+
expect(b).toMatchObject({ message: "a error" });
|
|
25
|
+
// Assign Err to Result
|
|
26
|
+
const c = a;
|
|
27
|
+
});
|
|
28
|
+
it("converts Oks", () => {
|
|
29
|
+
const a = Ok("a ok");
|
|
30
|
+
const b = Ok(a);
|
|
31
|
+
expect(b).toBe("a ok");
|
|
32
|
+
// Assign ok to Result
|
|
33
|
+
const c = a;
|
|
34
|
+
});
|
|
35
|
+
it("unwraps", () => {
|
|
36
|
+
const a = Some("some");
|
|
37
|
+
const b = None();
|
|
38
|
+
const c = Ok("ok");
|
|
39
|
+
const d = Err(new Error("err"));
|
|
40
|
+
const e = "else";
|
|
41
|
+
expect(unwrap(a)).toBe("some");
|
|
42
|
+
expect(unwrap(c)).toBe("ok");
|
|
43
|
+
expect(() => unwrap(b)).toThrow("Attempted to unwrap None");
|
|
44
|
+
expect(() => unwrap(d)).toThrow("err");
|
|
45
|
+
expect(unwrap(e)).toBe("else");
|
|
46
|
+
});
|
|
47
|
+
it("unwrapsOrs", () => {
|
|
48
|
+
const a = Some("some");
|
|
49
|
+
const b = None();
|
|
50
|
+
const c = Ok("ok");
|
|
51
|
+
const d = Err(new Error("err"));
|
|
52
|
+
const e = "else";
|
|
53
|
+
expect(unwrapOr(a, "z")).toBe("some");
|
|
54
|
+
expect(unwrapOr(c, "z")).toBe("ok");
|
|
55
|
+
expect(unwrapOr(b, "z")).toBe("z");
|
|
56
|
+
expect(unwrapOr(d, "z")).toBe("z");
|
|
57
|
+
expect(unwrapOr(e, "z")).toBe("else");
|
|
58
|
+
});
|
|
59
|
+
it("unwrapsOrElse", () => {
|
|
60
|
+
const a = Some("some");
|
|
61
|
+
const b = None();
|
|
62
|
+
const c = Ok("ok");
|
|
63
|
+
const d = Err(new Error("err"));
|
|
64
|
+
const e = "else";
|
|
65
|
+
expect(unwrapOrElse(a, () => "z")).toBe("some");
|
|
66
|
+
expect(unwrapOrElse(c, () => "z")).toBe("ok");
|
|
67
|
+
expect(unwrapOrElse(b, () => "z")).toBe("z");
|
|
68
|
+
expect(unwrapOrElse(d, () => "z")).toBe("z");
|
|
69
|
+
expect(unwrapOrElse(e, () => "z")).toBe("else");
|
|
70
|
+
});
|
|
71
|
+
});
|
package/build/safe.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const safe: <A extends unknown[], R>(fn: (...args: A) => R, r: R) => (...args: A) => R;
|
|
1
|
+
export declare const safe: <A extends unknown[], R>(fn: (...args: A) => R, r: R) => (...args: A) => R;
|
package/build/safe.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { error } from "./log.js";
|
|
2
|
-
export const safe = (fn, r) => (...args) => {
|
|
3
|
-
try {
|
|
4
|
-
return fn(...args);
|
|
5
|
-
}
|
|
6
|
-
catch (e) {
|
|
7
|
-
error(`${e}`);
|
|
8
|
-
return r;
|
|
9
|
-
}
|
|
10
|
-
};
|
|
1
|
+
import { error } from "./log.js";
|
|
2
|
+
export const safe = (fn, r) => (...args) => {
|
|
3
|
+
try {
|
|
4
|
+
return fn(...args);
|
|
5
|
+
}
|
|
6
|
+
catch (e) {
|
|
7
|
+
error(`${e}`);
|
|
8
|
+
return r;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { TestCase } from "./scope.js";
|
|
2
|
-
export declare const beforeall: unique symbol;
|
|
3
|
-
export declare const beforeeach: unique symbol;
|
|
4
|
-
export declare const afterall: unique symbol;
|
|
5
|
-
export declare const aftereach: unique symbol;
|
|
6
|
-
export declare function rootCases(): TestCase;
|
|
7
|
-
export declare function getTotalCases(): number;
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare function
|
|
1
|
+
import { TestCase } from "./scope.js";
|
|
2
|
+
export declare const beforeall: unique symbol;
|
|
3
|
+
export declare const beforeeach: unique symbol;
|
|
4
|
+
export declare const afterall: unique symbol;
|
|
5
|
+
export declare const aftereach: unique symbol;
|
|
6
|
+
export declare function rootCases(): TestCase;
|
|
7
|
+
export declare function getTotalCases(): number;
|
|
8
|
+
export declare function getSkippedCases(): number;
|
|
9
|
+
export declare function describe(title: string, block: Function): void;
|
|
10
|
+
export declare function it(title: string, block: Function): void;
|
|
11
|
+
export declare namespace it {
|
|
12
|
+
var skip: (title: string, _block: Function) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function beforeEach(fn: () => void): void;
|
|
15
|
+
export declare function beforeAll(fn: () => void): void;
|
|
16
|
+
export declare function afterEach(fn: () => void): void;
|
|
17
|
+
export declare function afterAll(fn: () => void): void;
|
|
18
|
+
export declare function cleanState<State extends {}>(init: () => State, runner?: (action: () => void) => void): State;
|
package/build/scope/describe.js
CHANGED
|
@@ -1,52 +1,61 @@
|
|
|
1
|
-
import { getLogger } from "../log.js";
|
|
2
|
-
export const beforeall = Symbol("beforeAll");
|
|
3
|
-
export const beforeeach = Symbol("beforeEach");
|
|
4
|
-
export const afterall = Symbol("afterAll");
|
|
5
|
-
export const aftereach = Symbol("afterEach");
|
|
6
|
-
const logger = getLogger("scope");
|
|
7
|
-
const CASES = {};
|
|
8
|
-
let cases = [CASES];
|
|
9
|
-
let totalCases = 0;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
cases
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
export function
|
|
44
|
-
cases[0][
|
|
45
|
-
}
|
|
46
|
-
export function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
import { getLogger } from "../log.js";
|
|
2
|
+
export const beforeall = Symbol("beforeAll");
|
|
3
|
+
export const beforeeach = Symbol("beforeEach");
|
|
4
|
+
export const afterall = Symbol("afterAll");
|
|
5
|
+
export const aftereach = Symbol("afterEach");
|
|
6
|
+
const logger = getLogger("scope");
|
|
7
|
+
const CASES = {};
|
|
8
|
+
let cases = [CASES];
|
|
9
|
+
let totalCases = 0;
|
|
10
|
+
let skippedCases = 0;
|
|
11
|
+
function push(title) {
|
|
12
|
+
const next = (cases[0][title] = {});
|
|
13
|
+
cases.unshift(next);
|
|
14
|
+
}
|
|
15
|
+
function pop() {
|
|
16
|
+
cases.shift();
|
|
17
|
+
}
|
|
18
|
+
export function rootCases() {
|
|
19
|
+
return CASES;
|
|
20
|
+
}
|
|
21
|
+
export function getTotalCases() {
|
|
22
|
+
return totalCases;
|
|
23
|
+
}
|
|
24
|
+
export function getSkippedCases() {
|
|
25
|
+
return skippedCases;
|
|
26
|
+
}
|
|
27
|
+
export function describe(title, block) {
|
|
28
|
+
logger.debug(`describe(${title})`);
|
|
29
|
+
push(title);
|
|
30
|
+
block();
|
|
31
|
+
pop();
|
|
32
|
+
}
|
|
33
|
+
export function it(title, block) {
|
|
34
|
+
logger.debug(`it(${title})`);
|
|
35
|
+
totalCases += 1;
|
|
36
|
+
cases[0][title] = block;
|
|
37
|
+
}
|
|
38
|
+
it.skip = (title, _block) => {
|
|
39
|
+
logger.debug(`it.skip(${title})`);
|
|
40
|
+
totalCases += 1;
|
|
41
|
+
skippedCases += 1;
|
|
42
|
+
};
|
|
43
|
+
export function beforeEach(fn) {
|
|
44
|
+
cases[0][beforeeach] = fn;
|
|
45
|
+
}
|
|
46
|
+
export function beforeAll(fn) {
|
|
47
|
+
cases[0][beforeall] = fn;
|
|
48
|
+
}
|
|
49
|
+
export function afterEach(fn) {
|
|
50
|
+
cases[0][aftereach] = fn;
|
|
51
|
+
}
|
|
52
|
+
export function afterAll(fn) {
|
|
53
|
+
cases[0][afterall] = fn;
|
|
54
|
+
}
|
|
55
|
+
export function cleanState(init, runner = beforeEach) {
|
|
56
|
+
const state = {};
|
|
57
|
+
runner(() => {
|
|
58
|
+
Object.assign(state, init());
|
|
59
|
+
});
|
|
60
|
+
return state;
|
|
61
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TestResult } from "../scope.js";
|
|
2
|
-
export declare function onConsole(results: TestResult): void;
|
|
1
|
+
import { TestResult } from "../scope.js";
|
|
2
|
+
export declare function onConsole(results: TestResult): void;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { getLogger } from "../../log.js";
|
|
2
|
-
import { getTotalCases } from "../describe.js";
|
|
3
|
-
import { flattenResults } from "../execute.js";
|
|
4
|
-
const logger = getLogger("Scope Test Runner");
|
|
5
|
-
export function onConsole(results) {
|
|
6
|
-
const { executed, failed } = results;
|
|
7
|
-
logger.info("Executed test suite.", {
|
|
8
|
-
executed,
|
|
9
|
-
total: getTotalCases(),
|
|
10
|
-
failed,
|
|
11
|
-
});
|
|
12
|
-
const flat = flattenResults(results);
|
|
13
|
-
for (const { test } of flat) {
|
|
14
|
-
logger.debug(test);
|
|
15
|
-
}
|
|
16
|
-
for (const { test, stack } of flat) {
|
|
17
|
-
if (stack) {
|
|
18
|
-
logger.error(test, { stack });
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
import { getLogger } from "../../log.js";
|
|
2
|
+
import { getTotalCases } from "../describe.js";
|
|
3
|
+
import { flattenResults } from "../execute.js";
|
|
4
|
+
const logger = getLogger("Scope Test Runner");
|
|
5
|
+
export function onConsole(results) {
|
|
6
|
+
const { executed, failed } = results;
|
|
7
|
+
logger.info("Executed test suite.", {
|
|
8
|
+
executed,
|
|
9
|
+
total: getTotalCases(),
|
|
10
|
+
failed,
|
|
11
|
+
});
|
|
12
|
+
const flat = flattenResults(results);
|
|
13
|
+
for (const { test } of flat) {
|
|
14
|
+
logger.debug(test);
|
|
15
|
+
}
|
|
16
|
+
for (const { test, stack } of flat) {
|
|
17
|
+
if (stack) {
|
|
18
|
+
logger.error(test, { stack });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DOMElement
|
|
2
|
-
import { TestResult } from "../scope.js";
|
|
3
|
-
export declare function displayStatistics(results: TestResult, root?:
|
|
1
|
+
import { DOMElement } from "../../dom/dom.js";
|
|
2
|
+
import { TestResult } from "../scope.js";
|
|
3
|
+
export declare function displayStatistics(results: TestResult, root?: DOMElement): void;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { isHTMLLogger, makeHTMLLogger } from "../../components/logger.js";
|
|
2
|
-
import { DEFAULT_LOGGER, LEVEL } from "../../log.js";
|
|
3
|
-
import { getTotalCases } from "../describe.js";
|
|
4
|
-
import { flattenResults } from "../execute.js";
|
|
5
|
-
export function displayStatistics(results, root = document.body) {
|
|
6
|
-
const { executed, failed } = results;
|
|
7
|
-
const logger = (() => {
|
|
8
|
-
try {
|
|
9
|
-
return makeHTMLLogger(`Executed ${executed} of ${getTotalCases()}; ${failed} failed.`);
|
|
10
|
-
}
|
|
11
|
-
catch (e) {
|
|
12
|
-
return DEFAULT_LOGGER;
|
|
13
|
-
}
|
|
14
|
-
})();
|
|
15
|
-
logger.level = LEVEL.DEBUG;
|
|
16
|
-
const flat = flattenResults(results);
|
|
17
|
-
for (const { test, stack } of flat) {
|
|
18
|
-
if (stack) {
|
|
19
|
-
logger.info(test);
|
|
20
|
-
logger.debug(`${stack}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (isHTMLLogger(logger)) {
|
|
24
|
-
root.appendChild(logger.root);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
1
|
+
import { isHTMLLogger, makeHTMLLogger } from "../../components/logger.js";
|
|
2
|
+
import { DEFAULT_LOGGER, LEVEL } from "../../log.js";
|
|
3
|
+
import { getTotalCases } from "../describe.js";
|
|
4
|
+
import { flattenResults } from "../execute.js";
|
|
5
|
+
export function displayStatistics(results, root = document.body) {
|
|
6
|
+
const { executed, failed } = results;
|
|
7
|
+
const logger = (() => {
|
|
8
|
+
try {
|
|
9
|
+
return makeHTMLLogger(`Executed ${executed} of ${getTotalCases()}; ${failed} failed.`);
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
return DEFAULT_LOGGER;
|
|
13
|
+
}
|
|
14
|
+
})();
|
|
15
|
+
logger.level = LEVEL.DEBUG;
|
|
16
|
+
const flat = flattenResults(results);
|
|
17
|
+
for (const { test, stack } of flat) {
|
|
18
|
+
if (stack) {
|
|
19
|
+
logger.info(test);
|
|
20
|
+
logger.debug(`${stack}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (isHTMLLogger(logger)) {
|
|
24
|
+
root.appendChild(logger.root);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TestResult } from "../scope.js";
|
|
2
|
-
export declare function asXML(results: TestResult): string;
|
|
1
|
+
import { TestResult } from "../scope.js";
|
|
2
|
+
export declare function asXML(results: TestResult): string;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { xml } from "../../dom/xml.js";
|
|
2
|
-
import { flattenResults } from "../execute.js";
|
|
3
|
-
const cases = (results) => Object.entries(results).filter(([key]) => !["executed", "passed", "failed"].includes(key));
|
|
4
|
-
export function asXML(results) {
|
|
5
|
-
return (`<?xml version="1.0" encoding="UTF-8" ?>` +
|
|
6
|
-
xml("testsuites", { tests: results.executed, failures: results.failed }, cases(results).map(([title, children]) => testsuite(title, children.executed, children.failed, flattenResults(children)))));
|
|
7
|
-
}
|
|
8
|
-
function testsuite(name, tests, failures, cases) {
|
|
9
|
-
const id = name.replace("s+", "_");
|
|
10
|
-
return xml("testsuite", { id, name, tests, failures }, cases.map(({ test, stack }) => testcase({ name: `${name} ${test}` }, stack ? [stack] : [])));
|
|
11
|
-
}
|
|
12
|
-
function testcase({ name, id = name.replace(/\s+/g, "_"), time = "0.00", }, failures) {
|
|
13
|
-
return xml("testcase", { id, name, time }, failures.map((stack) => failure({ text: stack })));
|
|
14
|
-
}
|
|
15
|
-
function failure({ text, message = text.split("\n")[0], }) {
|
|
16
|
-
return xml("failure", { message }, [`<![CDATA[${text}]]>`]);
|
|
17
|
-
}
|
|
1
|
+
import { xml } from "../../dom/xml.js";
|
|
2
|
+
import { flattenResults } from "../execute.js";
|
|
3
|
+
const cases = (results) => Object.entries(results).filter(([key]) => !["executed", "passed", "failed"].includes(key));
|
|
4
|
+
export function asXML(results) {
|
|
5
|
+
return (`<?xml version="1.0" encoding="UTF-8" ?>` +
|
|
6
|
+
xml("testsuites", { tests: results.executed, failures: results.failed }, cases(results).map(([title, children]) => testsuite(title, children.executed, children.failed, flattenResults(children)))));
|
|
7
|
+
}
|
|
8
|
+
function testsuite(name, tests, failures, cases) {
|
|
9
|
+
const id = name.replace("s+", "_");
|
|
10
|
+
return xml("testsuite", { id, name, tests, failures }, cases.map(({ test, stack }) => testcase({ name: `${name} ${test}` }, stack ? [stack] : [])));
|
|
11
|
+
}
|
|
12
|
+
function testcase({ name, id = name.replace(/\s+/g, "_"), time = "0.00", }, failures) {
|
|
13
|
+
return xml("testcase", { id, name, time }, failures.map((stack) => failure({ text: stack })));
|
|
14
|
+
}
|
|
15
|
+
function failure({ text, message = text.split("\n")[0], }) {
|
|
16
|
+
return xml("failure", { message }, [`<![CDATA[${text}]]>`]);
|
|
17
|
+
}
|
package/build/scope/execute.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { TestResult, TestSummary } from "./scope.js";
|
|
2
|
-
export declare function execute(prefix?: string, cases?: import("./scope.js").TestCase): Promise<TestResult>;
|
|
3
|
-
export declare function getError({ error }: TestResult): number | TestResult | TestSummary | "unknown error";
|
|
4
|
-
export interface FlatResult {
|
|
5
|
-
test: string;
|
|
6
|
-
stack?: string | number | TestResult | TestSummary;
|
|
7
|
-
stats: {
|
|
8
|
-
executed: number;
|
|
9
|
-
failed: number;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export declare function flattenResults(results: TestResult, prefix?: string): FlatResult[];
|
|
1
|
+
import { TestResult, TestSummary } from "./scope.js";
|
|
2
|
+
export declare function execute(prefix?: string, cases?: import("./scope.js").TestCase): Promise<TestResult>;
|
|
3
|
+
export declare function getError({ error }: TestResult): number | TestResult | TestSummary | "unknown error";
|
|
4
|
+
export interface FlatResult {
|
|
5
|
+
test: string;
|
|
6
|
+
stack?: string | number | TestResult | TestSummary;
|
|
7
|
+
stats: {
|
|
8
|
+
executed: number;
|
|
9
|
+
failed: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare function flattenResults(results: TestResult, prefix?: string): FlatResult[];
|