Skip to content

Commit 601e5ff

Browse files
committed
test: fix unit test failure due to missing file
1 parent fb01d10 commit 601e5ff

2 files changed

Lines changed: 34 additions & 11 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License").
5+
You may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
export class StatusCacheItem<T> {
18+
readonly status: T;
19+
20+
constructor(status: T) {
21+
this.status = status;
22+
}
23+
}

tests/unit/batching_event_publisher.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class TestableEventPublisher extends BatchingEventPublisher {
3535
return this.pendingEvents.size;
3636
}
3737

38-
triggerSendMessages(): void {
39-
this.sendMessages();
38+
async triggerSendMessages(): Promise<void> {
39+
await this.sendMessages();
4040
}
4141
}
4242

@@ -52,7 +52,7 @@ describe("BatchingEventPublisher", () => {
5252
publisher = new TestableEventPublisher();
5353
processEventCalls = [];
5454
mockSubscriber = {
55-
processEvent: (event: Event) => {
55+
processEvent: async (event: Event) => {
5656
processEventCalls.push(event);
5757
}
5858
};
@@ -62,7 +62,7 @@ describe("BatchingEventPublisher", () => {
6262
publisher.releaseResources();
6363
});
6464

65-
it("should publish events to subscribers and deduplicate", () => {
65+
it("should publish events to subscribers and deduplicate", async () => {
6666
const eventSubscriptions = new Set([DataAccessEvent]);
6767

6868
publisher.subscribe(mockSubscriber, eventSubscriptions);
@@ -73,7 +73,7 @@ describe("BatchingEventPublisher", () => {
7373
publisher.publish(event);
7474
publisher.publish(event);
7575

76-
publisher.triggerSendMessages();
76+
await publisher.triggerSendMessages();
7777

7878
expect(publisher.pendingEventCount).toBe(0);
7979

@@ -82,7 +82,7 @@ describe("BatchingEventPublisher", () => {
8282

8383
publisher.unsubscribe(mockSubscriber, eventSubscriptions);
8484
publisher.publish(event);
85-
publisher.triggerSendMessages();
85+
await publisher.triggerSendMessages();
8686

8787
expect(publisher.pendingEventCount).toBe(0);
8888

@@ -105,23 +105,23 @@ describe("BatchingEventPublisher", () => {
105105
expect(publisher.pendingEventCount).toBe(0);
106106
});
107107

108-
it("should not deliver events to unsubscribed subscribers", () => {
108+
it("should not deliver events to unsubscribed subscribers", async () => {
109109
const eventSubscriptions = new Set([DataAccessEvent]);
110110

111111
publisher.subscribe(mockSubscriber, eventSubscriptions);
112112
publisher.unsubscribe(mockSubscriber, eventSubscriptions);
113113

114114
const event = new DataAccessEvent(TestDataClass, "key");
115115
publisher.publish(event);
116-
publisher.triggerSendMessages();
116+
await publisher.triggerSendMessages();
117117

118118
expect(processEventCalls.length).toBe(0);
119119
});
120120

121-
it("should handle multiple subscribers", () => {
121+
it("should handle multiple subscribers", async () => {
122122
const processEventCalls2: Event[] = [];
123123
const mockSubscriber2: EventSubscriber = {
124-
processEvent: (event: Event) => {
124+
processEvent: async (event: Event) => {
125125
processEventCalls2.push(event);
126126
}
127127
};
@@ -133,7 +133,7 @@ describe("BatchingEventPublisher", () => {
133133

134134
const event = new DataAccessEvent(TestDataClass, "key");
135135
publisher.publish(event);
136-
publisher.triggerSendMessages();
136+
await publisher.triggerSendMessages();
137137

138138
expect(processEventCalls.length).toBe(1);
139139
expect(processEventCalls2.length).toBe(1);

0 commit comments

Comments
 (0)