@rcompat/test 0.11.0 → 0.11.1
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/lib/private/extend.d.ts +19 -0
- package/lib/private/extend.js +14 -0
- package/lib/private/index.d.ts +7 -4
- package/lib/private/index.js +8 -1
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type Assert from "#Assert";
|
|
2
|
+
import type Asserter from "#Asserter";
|
|
3
|
+
import type Body from "#Body";
|
|
4
|
+
import type { MaybePromise } from "@rcompat/type";
|
|
5
|
+
type ExtendedAssert<T, Extensions> = Assert<T> & Extensions;
|
|
6
|
+
type ExtendedAsserter<Extensions> = <const T>(actual?: T) => ExtendedAssert<T, Extensions>;
|
|
7
|
+
type ExtendedBody<Extensions> = (asserter: ExtendedAsserter<Extensions>) => MaybePromise<void>;
|
|
8
|
+
export type Factory<Subject, Extensions> = (assert: Asserter, subject: Subject) => Extensions;
|
|
9
|
+
export type ExtendedTest<Extensions> = {
|
|
10
|
+
case(name: string, body: ExtendedBody<Extensions>): void;
|
|
11
|
+
ended(end: () => MaybePromise<void>): void;
|
|
12
|
+
};
|
|
13
|
+
type Base = {
|
|
14
|
+
case(name: string, body: Body): void;
|
|
15
|
+
ended(end: () => MaybePromise<void>): void;
|
|
16
|
+
};
|
|
17
|
+
declare const _default: <Subject, Extensions>(base: Base, factory: Factory<Subject, Extensions>) => ExtendedTest<Extensions>;
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=extend.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default (base, factory) => ({
|
|
2
|
+
case(name, body) {
|
|
3
|
+
base.case(name, asserter => {
|
|
4
|
+
const extended = (actual) => {
|
|
5
|
+
const a = asserter(actual);
|
|
6
|
+
const extra = factory(asserter, actual);
|
|
7
|
+
return Object.assign(Object.create(a), extra);
|
|
8
|
+
};
|
|
9
|
+
return body(extended);
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
ended: base.ended.bind(base),
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=extend.js.map
|
package/lib/private/index.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import type Asserter from "#Asserter";
|
|
1
2
|
import type Body from "#Body";
|
|
2
3
|
import type End from "#End";
|
|
4
|
+
import type Env from "#Env";
|
|
5
|
+
import type Result from "#Result";
|
|
6
|
+
import type Test from "#Test";
|
|
7
|
+
import type { ExtendedTest, Factory } from "#extend";
|
|
3
8
|
declare const _default: {
|
|
9
|
+
extend<Subject, Extensions>(factory: Factory<Subject, Extensions>): ExtendedTest<Extensions>;
|
|
4
10
|
case(name: string, body: Body): void;
|
|
5
11
|
ended(end: End): void;
|
|
6
12
|
};
|
|
7
13
|
export default _default;
|
|
8
|
-
export type {
|
|
9
|
-
export type { default as Env } from "#Env";
|
|
10
|
-
export type { default as Result } from "#Result";
|
|
11
|
-
export type { default as Test } from "#Test";
|
|
14
|
+
export type { Asserter, Env, ExtendedTest, Result, Test };
|
|
12
15
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/private/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import extend from "#extend";
|
|
1
2
|
import repository from "#repository";
|
|
2
|
-
|
|
3
|
+
const base = {
|
|
3
4
|
case(name, body) {
|
|
4
5
|
repository.put(name, body);
|
|
5
6
|
},
|
|
@@ -7,4 +8,10 @@ export default {
|
|
|
7
8
|
repository.ended(end);
|
|
8
9
|
},
|
|
9
10
|
};
|
|
11
|
+
export default {
|
|
12
|
+
...base,
|
|
13
|
+
extend(factory) {
|
|
14
|
+
return extend(base, factory);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
10
17
|
//# sourceMappingURL=index.js.map
|