Skip to content

Commit 053fa6d

Browse files
feat: add non-static getName() method to PostUpdatedEvent
Adds instance method that delegates to static method, consistent with other event classes like PostLikedEvent. Co-authored-by: Michael Barrett <mike182uk@users.noreply.github.com>
1 parent 3c8c8d8 commit 053fa6d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/post/post-updated.event.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ export class PostUpdatedEvent implements SerializableEvent {
77
return this.postId;
88
}
99

10+
getName(): string {
11+
return PostUpdatedEvent.getName();
12+
}
13+
1014
static getName(): string {
1115
return 'post.updated';
1216
}

src/post/post-updated.event.unit.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ describe('PostUpdatedEvent', () => {
3333
);
3434
});
3535

36-
it('should return the correct event name', () => {
36+
it('should return the correct event name from static method', () => {
3737
expect(PostUpdatedEvent.getName()).toEqual('post.updated');
3838
});
39+
40+
it('should return the correct event name from instance method', () => {
41+
const event = new PostUpdatedEvent(123);
42+
expect(event.getName()).toEqual('post.updated');
43+
});
3944
});

0 commit comments

Comments
 (0)