Skip to content

Commit

Permalink
test(): modify test for the expected alias behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
matt1097 committed Aug 10, 2022
1 parent 79c9ce7 commit 4ba1837
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/e2e/module-e2e.spec.ts
Expand Up @@ -29,6 +29,7 @@ describe('EventEmitterModule - e2e', () => {
await app.init();

expect(eventsConsumerRef.eventPayload).toEqual(TEST_EVENT_PAYLOAD);
expect(eventsConsumerRef.eventReceiveCount).toEqual(1);
});

it(`should emit a "test-event" event to controllers`, async () => {
Expand Down
4 changes: 4 additions & 0 deletions tests/src/app.module.ts
Expand Up @@ -20,6 +20,10 @@ import { TestProvider } from './test-provider';
EventsProducer,
TestProvider,
EventsProviderRequestScopedConsumer,
{
provide: 'AnAliasedConsumer',
useExisting: EventsProviderConsumer,
},
],
})
export class AppModule {}
2 changes: 2 additions & 0 deletions tests/src/events-provider.consumer.ts
Expand Up @@ -4,9 +4,11 @@ import { OnEvent } from '../../lib';
@Injectable()
export class EventsProviderConsumer {
public eventPayload = {};
public eventReceiveCount = 0;

@OnEvent('test.*')
onTestEvent(payload: Record<string, any>) {
this.eventPayload = payload;
this.eventReceiveCount++;
}
}

0 comments on commit 4ba1837

Please sign in to comment.