@relaybus/testing 0.2.0 → 0.3.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/README.md +5 -0
- package/dist/index.cjs +1266 -1187
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -6
- package/dist/index.d.ts +19 -6
- package/dist/index.js +1266 -1187
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NewDelivery, EventEnvelope, EventStore, Clock, Transport, TransportMessageHandler } from '@relaybus/core';
|
|
2
|
+
|
|
3
|
+
declare function at(offsetMs: number): Date;
|
|
4
|
+
declare function createEnvelope(overrides?: Partial<EventEnvelope>): EventEnvelope;
|
|
5
|
+
declare function createDelivery(handler: string, availableAt?: Date): NewDelivery;
|
|
2
6
|
|
|
3
7
|
interface EventStoreContractOptions<TTransaction> {
|
|
4
8
|
/** Creates an empty, set-up store. Called before every test. */
|
|
@@ -18,9 +22,6 @@ interface EventStoreContractOptions<TTransaction> {
|
|
|
18
22
|
*/
|
|
19
23
|
readonly keepsCompletedRecords?: boolean;
|
|
20
24
|
}
|
|
21
|
-
declare function at(offsetMs: number): Date;
|
|
22
|
-
declare function createEnvelope(overrides?: Partial<EventEnvelope>): EventEnvelope;
|
|
23
|
-
declare function createDelivery(handler: string, availableAt?: Date): NewDelivery;
|
|
24
25
|
/**
|
|
25
26
|
* Behaviour every {@link EventStore} must have. Call it inside a test file of
|
|
26
27
|
* the store package:
|
|
@@ -31,13 +32,25 @@ declare function createDelivery(handler: string, availableAt?: Date): NewDeliver
|
|
|
31
32
|
*/
|
|
32
33
|
declare function eventStoreContract<TTransaction>(name: string, options: EventStoreContractOptions<TTransaction>): void;
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
type ScheduledTask = Parameters<NonNullable<Clock['schedule']>>[0];
|
|
36
|
+
/**
|
|
37
|
+
* Clock that only moves when told to. With `controlTimers: true` it also owns relaybus's timers
|
|
38
|
+
* (polling, retries, heartbeats, retention, timeouts): they run inside {@link FakeClock.advance}
|
|
39
|
+
* when their time comes instead of on the platform timers. Without it, timers stay real.
|
|
40
|
+
*/
|
|
35
41
|
declare class FakeClock implements Clock {
|
|
36
42
|
#private;
|
|
37
|
-
|
|
43
|
+
/** Present only with `controlTimers: true`; see {@link Clock.schedule}. */
|
|
44
|
+
readonly schedule?: (task: ScheduledTask) => () => void;
|
|
45
|
+
constructor(start?: Date | string | number, options?: {
|
|
46
|
+
readonly controlTimers?: boolean;
|
|
47
|
+
});
|
|
38
48
|
now(): Date;
|
|
49
|
+
/** Moves the clock forward, running every controlled timer that falls due on the way, in time order. */
|
|
39
50
|
advance(milliseconds: number): Date;
|
|
40
51
|
set(instant: Date | string | number): Date;
|
|
52
|
+
/** Controlled timers still waiting to run. */
|
|
53
|
+
get pendingTimers(): number;
|
|
41
54
|
}
|
|
42
55
|
|
|
43
56
|
interface PublishedMessage {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NewDelivery, EventEnvelope, EventStore, Clock, Transport, TransportMessageHandler } from '@relaybus/core';
|
|
2
|
+
|
|
3
|
+
declare function at(offsetMs: number): Date;
|
|
4
|
+
declare function createEnvelope(overrides?: Partial<EventEnvelope>): EventEnvelope;
|
|
5
|
+
declare function createDelivery(handler: string, availableAt?: Date): NewDelivery;
|
|
2
6
|
|
|
3
7
|
interface EventStoreContractOptions<TTransaction> {
|
|
4
8
|
/** Creates an empty, set-up store. Called before every test. */
|
|
@@ -18,9 +22,6 @@ interface EventStoreContractOptions<TTransaction> {
|
|
|
18
22
|
*/
|
|
19
23
|
readonly keepsCompletedRecords?: boolean;
|
|
20
24
|
}
|
|
21
|
-
declare function at(offsetMs: number): Date;
|
|
22
|
-
declare function createEnvelope(overrides?: Partial<EventEnvelope>): EventEnvelope;
|
|
23
|
-
declare function createDelivery(handler: string, availableAt?: Date): NewDelivery;
|
|
24
25
|
/**
|
|
25
26
|
* Behaviour every {@link EventStore} must have. Call it inside a test file of
|
|
26
27
|
* the store package:
|
|
@@ -31,13 +32,25 @@ declare function createDelivery(handler: string, availableAt?: Date): NewDeliver
|
|
|
31
32
|
*/
|
|
32
33
|
declare function eventStoreContract<TTransaction>(name: string, options: EventStoreContractOptions<TTransaction>): void;
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
type ScheduledTask = Parameters<NonNullable<Clock['schedule']>>[0];
|
|
36
|
+
/**
|
|
37
|
+
* Clock that only moves when told to. With `controlTimers: true` it also owns relaybus's timers
|
|
38
|
+
* (polling, retries, heartbeats, retention, timeouts): they run inside {@link FakeClock.advance}
|
|
39
|
+
* when their time comes instead of on the platform timers. Without it, timers stay real.
|
|
40
|
+
*/
|
|
35
41
|
declare class FakeClock implements Clock {
|
|
36
42
|
#private;
|
|
37
|
-
|
|
43
|
+
/** Present only with `controlTimers: true`; see {@link Clock.schedule}. */
|
|
44
|
+
readonly schedule?: (task: ScheduledTask) => () => void;
|
|
45
|
+
constructor(start?: Date | string | number, options?: {
|
|
46
|
+
readonly controlTimers?: boolean;
|
|
47
|
+
});
|
|
38
48
|
now(): Date;
|
|
49
|
+
/** Moves the clock forward, running every controlled timer that falls due on the way, in time order. */
|
|
39
50
|
advance(milliseconds: number): Date;
|
|
40
51
|
set(instant: Date | string | number): Date;
|
|
52
|
+
/** Controlled timers still waiting to run. */
|
|
53
|
+
get pendingTimers(): number;
|
|
41
54
|
}
|
|
42
55
|
|
|
43
56
|
interface PublishedMessage {
|