-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): refactor tests to use constant event payloads instead of m…
…anual declaration
- Loading branch information
1 parent
afeeb0c
commit 929a3ea
Showing
3 changed files
with
33 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const TEST_EVENT_PAYLOAD = { | ||
test: 'event', | ||
}; | ||
|
||
export const TEST_EVENT_MULTIPLE_PAYLOAD = [ | ||
TEST_EVENT_PAYLOAD, | ||
{ | ||
test2: 'event2', | ||
}, | ||
]; | ||
|
||
export const TEST_EVENT_STRING_PAYLOAD = 'some-string'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
import { Injectable, OnApplicationBootstrap } from '@nestjs/common'; | ||
import { EventEmitter2 } from 'eventemitter2'; | ||
import { | ||
TEST_EVENT_MULTIPLE_PAYLOAD, | ||
TEST_EVENT_PAYLOAD, | ||
TEST_EVENT_STRING_PAYLOAD, | ||
} from './constants'; | ||
|
||
@Injectable() | ||
export class EventsProducer implements OnApplicationBootstrap { | ||
constructor(private readonly eventEmitter: EventEmitter2) {} | ||
|
||
onApplicationBootstrap() { | ||
this.eventEmitter.emit('test.event', { test: 'event' }); | ||
this.eventEmitter.emit( | ||
'multiple.event', | ||
{ test: 'event' }, | ||
{ test2: 'event2' }, | ||
); | ||
this.eventEmitter.emit('string.event', 'some-string'); | ||
this.eventEmitter.emit('test.event', TEST_EVENT_PAYLOAD); | ||
this.eventEmitter.emit('multiple.event', TEST_EVENT_MULTIPLE_PAYLOAD); | ||
this.eventEmitter.emit('string.event', TEST_EVENT_STRING_PAYLOAD); | ||
} | ||
} |