@rcompat/test 0.3.0 → 0.5.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.
@@ -0,0 +1,4 @@
1
+ import type MaybePromise from "@rcompat/type/MaybePromise";
2
+ type End = () => MaybePromise<void>;
3
+ export type { End as default };
4
+ //# sourceMappingURL=End.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=End.js.map
@@ -0,0 +1,14 @@
1
+ import type Body from "#Body";
2
+ import type End from "#End";
3
+ import Test from "#Test";
4
+ import type FileRef from "@rcompat/fs/FileRef";
5
+ export default class Suite {
6
+ #private;
7
+ constructor(file: FileRef);
8
+ test(name: string, body: Body): void;
9
+ ended(end: End): void;
10
+ get file(): FileRef;
11
+ run(): AsyncGenerator<Test, void, unknown>;
12
+ end(): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=Suite.d.ts.map
@@ -0,0 +1,29 @@
1
+ import Test from "#Test";
2
+ export default class Suite {
3
+ #file;
4
+ #tests = [];
5
+ #ends = [];
6
+ constructor(file) {
7
+ this.#file = file;
8
+ }
9
+ test(name, body) {
10
+ this.#tests.push(new Test(name, body));
11
+ }
12
+ ended(end) {
13
+ this.#ends.push(end);
14
+ }
15
+ get file() {
16
+ return this.#file;
17
+ }
18
+ async *run() {
19
+ for (const test of this.#tests) {
20
+ yield await test.run();
21
+ }
22
+ }
23
+ async end() {
24
+ for (const end of this.#ends) {
25
+ await end();
26
+ }
27
+ }
28
+ }
29
+ //# sourceMappingURL=Suite.js.map
@@ -1,11 +1,9 @@
1
1
  import type Body from "#Body";
2
2
  import Result from "#Result";
3
- import type FileRef from "@rcompat/fs/FileRef";
4
3
  export default class Test {
5
4
  #private;
6
- constructor(name: string, body: Body, file: FileRef);
5
+ constructor(name: string, body: Body);
7
6
  get name(): string;
8
- get file(): FileRef;
9
7
  get results(): Result<unknown>[];
10
8
  report<T>(actual: T, expected: T, passed: boolean): void;
11
9
  run(): Promise<this>;
@@ -4,18 +4,13 @@ export default class Test {
4
4
  #name;
5
5
  #body;
6
6
  #results = [];
7
- #file;
8
- constructor(name, body, file) {
7
+ constructor(name, body) {
9
8
  this.#name = name;
10
9
  this.#body = body;
11
- this.#file = file;
12
10
  }
13
11
  get name() {
14
12
  return this.#name;
15
13
  }
16
- get file() {
17
- return this.#file;
18
- }
19
14
  get results() {
20
15
  return this.#results;
21
16
  }
@@ -1,6 +1,8 @@
1
1
  import type Body from "#Body";
2
+ import type End from "#End";
2
3
  declare const _default: {
3
4
  case(name: string, body: Body): void;
5
+ ended(end: End): void;
4
6
  };
5
7
  export default _default;
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -3,5 +3,8 @@ export default {
3
3
  case(name, body) {
4
4
  repository.put(name, body);
5
5
  },
6
+ ended(end) {
7
+ repository.ended(end);
8
+ },
6
9
  };
7
10
  //# sourceMappingURL=index.js.map
@@ -1,12 +1,14 @@
1
1
  import type Body from "#Body";
2
- import Test from "#Test";
2
+ import type End from "#End";
3
+ import Suite from "#Suite";
3
4
  import type FileRef from "@rcompat/fs/FileRef";
4
5
  declare class Repository {
5
6
  #private;
6
- reset(): void;
7
7
  put(name: string, body: Body): void;
8
- current(file: FileRef): void;
9
- run(): AsyncGenerator<Test, void, unknown>;
8
+ ended(end: End): void;
9
+ suite(file: FileRef): void;
10
+ reset(): void;
11
+ next(): Generator<Suite, void, unknown>;
10
12
  }
11
13
  declare const _default: Repository;
12
14
  export default _default;
@@ -1,19 +1,24 @@
1
- import Test from "#Test";
1
+ import Suite from "#Suite";
2
2
  class Repository {
3
- #tests = [];
4
- #current;
5
- reset() {
6
- this.#tests = [];
3
+ #suites = [];
4
+ get #suite() {
5
+ return this.#suites.at(-1);
7
6
  }
8
7
  put(name, body) {
9
- this.#tests.push(new Test(name, body, this.#current));
8
+ this.#suite.test(name, body);
9
+ }
10
+ ended(end) {
11
+ this.#suite.ended(end);
10
12
  }
11
- current(file) {
12
- this.#current = file;
13
+ suite(file) {
14
+ this.#suites.push(new Suite(file));
15
+ }
16
+ reset() {
17
+ this.#suites = [];
13
18
  }
14
- async *run() {
15
- for (const test of this.#tests) {
16
- yield await test.run();
19
+ *next() {
20
+ for (const suite of this.#suites) {
21
+ yield suite;
17
22
  }
18
23
  }
19
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rcompat/test",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Standard library testing",
5
5
  "bugs": "https://github.com/rcompat/rcompat/issues",
6
6
  "license": "MIT",
@@ -15,10 +15,7 @@
15
15
  "directory": "packages/test"
16
16
  },
17
17
  "devDependencies": {
18
- "@rcompat/fs": "^0.13.2"
19
- },
20
- "dependencies": {
21
- "@rcompat/record": "^0.8.1"
18
+ "@rcompat/fs": "^0.17.0"
22
19
  },
23
20
  "type": "module",
24
21
  "imports": {