@sprucelabs/mercury-chunking-emitter 2.1.0 → 2.2.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.
|
@@ -8,12 +8,14 @@ export default class MockChunkingEmitter implements ChunkingEmitter {
|
|
|
8
8
|
static lastInstance?: MockChunkingEmitter;
|
|
9
9
|
private emittedTarget?;
|
|
10
10
|
private emittedCursor?;
|
|
11
|
+
private emittedPayload?;
|
|
11
12
|
constructor();
|
|
12
13
|
static getLastInstance(): MockChunkingEmitter;
|
|
13
14
|
static reset(): void;
|
|
14
15
|
emit(options: ChunkingEmitterEmitOptions): Promise<void>;
|
|
15
16
|
assertDidEmitTarget(target: Record<string, any>): void;
|
|
16
17
|
assertDidEmitPayloadKey(payloadKey: string): void;
|
|
18
|
+
assertEmittedPayloadIncludes(payload: Record<string, any>): void;
|
|
17
19
|
assertDidReceiveCursor(): void;
|
|
18
20
|
getTotalErrors(): number;
|
|
19
21
|
assertEmittedItems(items: Record<string, any>[]): void;
|
|
@@ -16,13 +16,14 @@ class MockChunkingEmitter {
|
|
|
16
16
|
this.lastInstance = undefined;
|
|
17
17
|
}
|
|
18
18
|
async emit(options) {
|
|
19
|
-
const { eventName, items, payloadKey, target, batchCursor: cursor, } = options;
|
|
19
|
+
const { eventName, items, payloadKey, target, batchCursor: cursor, payload, } = options;
|
|
20
20
|
this.didEmit = true;
|
|
21
21
|
this.emittedEventName = eventName;
|
|
22
22
|
this.emittedItems = items;
|
|
23
23
|
this.emittedPayloadKey = payloadKey;
|
|
24
24
|
this.emittedTarget = target;
|
|
25
25
|
this.emittedCursor = cursor;
|
|
26
|
+
this.emittedPayload = payload;
|
|
26
27
|
}
|
|
27
28
|
assertDidEmitTarget(target) {
|
|
28
29
|
test_utils_1.assert.isEqualDeep(this.emittedTarget, target, 'You did not chunkingEmitter.emit(...) the expected target!');
|
|
@@ -31,6 +32,10 @@ class MockChunkingEmitter {
|
|
|
31
32
|
this.assertDidEmit();
|
|
32
33
|
test_utils_1.assert.isEqual(this.emittedPayloadKey, payloadKey, `I expected chunkingEmitter.emit() with payloadKey '${payloadKey}'! But you emitted ${this.emittedPayloadKey || 'nothing'}`);
|
|
33
34
|
}
|
|
35
|
+
assertEmittedPayloadIncludes(payload) {
|
|
36
|
+
this.assertDidEmit();
|
|
37
|
+
test_utils_1.assert.doesInclude(this.emittedPayload, payload);
|
|
38
|
+
}
|
|
34
39
|
assertDidReceiveCursor() {
|
|
35
40
|
test_utils_1.assert.isTruthy(this.emittedCursor, 'You did not chunkingEmitter.emit(...) the expected batch cursor!');
|
|
36
41
|
}
|
|
@@ -8,12 +8,14 @@ export default class MockChunkingEmitter implements ChunkingEmitter {
|
|
|
8
8
|
static lastInstance?: MockChunkingEmitter;
|
|
9
9
|
private emittedTarget?;
|
|
10
10
|
private emittedCursor?;
|
|
11
|
+
private emittedPayload?;
|
|
11
12
|
constructor();
|
|
12
13
|
static getLastInstance(): MockChunkingEmitter;
|
|
13
14
|
static reset(): void;
|
|
14
15
|
emit(options: ChunkingEmitterEmitOptions): Promise<void>;
|
|
15
16
|
assertDidEmitTarget(target: Record<string, any>): void;
|
|
16
17
|
assertDidEmitPayloadKey(payloadKey: string): void;
|
|
18
|
+
assertEmittedPayloadIncludes(payload: Record<string, any>): void;
|
|
17
19
|
assertDidReceiveCursor(): void;
|
|
18
20
|
getTotalErrors(): number;
|
|
19
21
|
assertEmittedItems(items: Record<string, any>[]): void;
|
|
@@ -24,13 +24,14 @@ export default class MockChunkingEmitter {
|
|
|
24
24
|
}
|
|
25
25
|
emit(options) {
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
const { eventName, items, payloadKey, target, batchCursor: cursor, } = options;
|
|
27
|
+
const { eventName, items, payloadKey, target, batchCursor: cursor, payload, } = options;
|
|
28
28
|
this.didEmit = true;
|
|
29
29
|
this.emittedEventName = eventName;
|
|
30
30
|
this.emittedItems = items;
|
|
31
31
|
this.emittedPayloadKey = payloadKey;
|
|
32
32
|
this.emittedTarget = target;
|
|
33
33
|
this.emittedCursor = cursor;
|
|
34
|
+
this.emittedPayload = payload;
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
assertDidEmitTarget(target) {
|
|
@@ -40,6 +41,10 @@ export default class MockChunkingEmitter {
|
|
|
40
41
|
this.assertDidEmit();
|
|
41
42
|
assert.isEqual(this.emittedPayloadKey, payloadKey, `I expected chunkingEmitter.emit() with payloadKey '${payloadKey}'! But you emitted ${this.emittedPayloadKey || 'nothing'}`);
|
|
42
43
|
}
|
|
44
|
+
assertEmittedPayloadIncludes(payload) {
|
|
45
|
+
this.assertDidEmit();
|
|
46
|
+
assert.doesInclude(this.emittedPayload, payload);
|
|
47
|
+
}
|
|
43
48
|
assertDidReceiveCursor() {
|
|
44
49
|
assert.isTruthy(this.emittedCursor, 'You did not chunkingEmitter.emit(...) the expected batch cursor!');
|
|
45
50
|
}
|