@sprucelabs/mercury-chunking-emitter 1.0.4 → 1.1.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/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # [1.1.0](https://github.com/sprucelabsai-community/spruce-chunking-emitter/compare/v1.0.5...v1.1.0) (2023-10-21)
2
+
3
+
4
+ ### Features
5
+
6
+ * mock chunk fix ([1fdee23](https://github.com/sprucelabsai-community/spruce-chunking-emitter/commit/1fdee23))
7
+
8
+ ## [1.0.5](https://github.com/sprucelabsai-community/spruce-chunking-emitter/compare/v1.0.4...v1.0.5) (2023-10-21)
9
+
1
10
  ## [1.0.4](https://github.com/sprucelabsai-community/spruce-chunking-emitter/compare/v1.0.3...v1.0.4) (2023-10-21)
2
11
 
3
12
  ## [1.0.3](https://github.com/sprucelabsai-community/spruce-chunking-emitter/compare/v1.0.2...v1.0.3) (2023-10-21)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprucelabs/mercury-chunking-emitter",
3
- "version": "1.0.4",
3
+ "version": "1.1.1",
4
4
  "scripts": {
5
5
  "build.ci": "yarn build.tsc && yarn build.resolve-paths && yarn lint",
6
6
  "build.dev": "yarn build.tsc --sourceMap ; yarn resolve-paths.lint",
@@ -118,6 +118,17 @@ export default class TestingChunkingEmitterTest extends AbstractChunkingEmitterT
118
118
  })
119
119
  }
120
120
 
121
+ @test()
122
+ protected static async canGetMockInstance() {
123
+ assert.isEqual(MockChunkingEmitter.getLastInstance(), this.emitter)
124
+ }
125
+
126
+ @test()
127
+ protected static async throwsIfNoInstance() {
128
+ MockChunkingEmitter.reset()
129
+ assert.doesThrow(() => MockChunkingEmitter.getLastInstance())
130
+ }
131
+
121
132
  private static assertChunkFieldThrowsWithBadMatch(
122
133
  chunkSig: FieldDefinitions
123
134
  ) {
@@ -9,6 +9,23 @@ export default class MockChunkingEmitter implements ChunkingEmitter {
9
9
  private emittedEventName?: EventName
10
10
  private emittedItems?: Record<string, unknown>[]
11
11
  private emittedPayloadKey?: string
12
+ public static lastInstance?: MockChunkingEmitter
13
+
14
+ public constructor() {
15
+ MockChunkingEmitter.lastInstance = this
16
+ }
17
+
18
+ public static getLastInstance() {
19
+ assert.isTruthy(
20
+ this.lastInstance,
21
+ 'You have not constructed a ChunkingEmitter! Try ChunkingEmitterImpl.Emitter({})'
22
+ )
23
+ return this.lastInstance
24
+ }
25
+
26
+ public static reset() {
27
+ this.lastInstance = undefined
28
+ }
12
29
 
13
30
  public async emit(options: {
14
31
  eventName: EventName