From acdd9622d2ababa4a59ee1d0d04a816791f5d795 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Mon, 9 Nov 2015 16:51:39 -0800 Subject: [PATCH] [Topic] Add test case ...which specifies desired behavior for nasa/openmctweb#231. --- platform/core/test/services/TopicSpec.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/platform/core/test/services/TopicSpec.js b/platform/core/test/services/TopicSpec.js index b389b19579..e3732cc240 100644 --- a/platform/core/test/services/TopicSpec.js +++ b/platform/core/test/services/TopicSpec.js @@ -65,6 +65,21 @@ define( expect(mockCallback).toHaveBeenCalledWith(testMessage); }); + it("is robust against errors thrown by listeners", function () { + var mockBadCallback = jasmine.createSpy("bad-callback"), + t = topic(); + + mockBadCallback.andCallFake(function () { + throw new Error("I'm afraid I can't do that."); + }); + + t.listen(mockBadCallback); + t.listen(mockCallback); + + t.notify(testMessage); + expect(mockCallback).toHaveBeenCalledWith(testMessage); + }); + }); } );