Skip to content

Commit 1017647

Browse files
author
Dustin Cleveland
committed
Fix #3
1 parent 56de03a commit 1017647

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/angular2-pubsub.service.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ describe('PubSubService', (): void => {
3333
expect(pubService.$pub.bind(undefined)).toThrow();
3434
});
3535

36-
it('should throw an error when event is not registered', (): void => {
37-
expect(pubService.$pub.bind('not-registered')).toThrow();
36+
it('should do nothing when an event is not registered', (): void => {
37+
expect(() => pubService.$pub('not-registered')).not.toThrow();
3838
});
3939

4040
it('should publish with parameters if the event is registered', (): void => {

src/angular2-pubsub.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class PubSubService implements IPubSubService {
3535
if (!event) {
3636
throw new Error(`[${ServiceName}] => Publish method must get event name.`);
3737
} else if (!this.events[event]) {
38-
throw new Error(`[${ServiceName}] => No recorded events found for ${event}.`);
38+
return;
3939
}
4040

4141
this.events[event].next(eventObject);

0 commit comments

Comments
 (0)