From b48dd4b63b8d9477881db4a22b3776ab33a47a51 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 4 Apr 2017 11:35:49 -0700 Subject: [PATCH] [Testing] Test start event on MCT --- src/MCTSpec.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/MCTSpec.js b/src/MCTSpec.js index 7742d85db2..2aa1dc0abd 100644 --- a/src/MCTSpec.js +++ b/src/MCTSpec.js @@ -22,27 +22,46 @@ define([ './MCT', - './plugins/plugins' -], function (MCT, plugins) { + './plugins/plugins', + 'legacyRegistry' +], function (MCT, plugins, legacyRegistry) { describe("MCT", function () { var openmct; var mockPlugin; var mockPlugin2; + var mockListener; + var oldBundles; beforeEach(function () { mockPlugin = jasmine.createSpy('plugin'); - mockPlugin2 = jasmine.createSpy('plugin'); + mockPlugin2 = jasmine.createSpy('plugin2'); + mockListener = jasmine.createSpy('listener'); + oldBundles = legacyRegistry.list(); openmct = new MCT(); openmct.install(mockPlugin); openmct.install(mockPlugin2); + openmct.on('start', mockListener); + }); + + // Clean up the dirty singleton. + afterEach(function () { + legacyRegistry.list().forEach(function (bundle) { + if (oldBundles.indexOf(bundle) === -1) { + legacyRegistry.delete(bundle); + } + }); }); it("exposes plugins", function () { expect(openmct.plugins).toEqual(plugins); }); + it("does not issue a start event before started", function () { + expect(mockListener).not.toHaveBeenCalled(); + }); + describe("start", function () { beforeEach(function () { openmct.start(); @@ -52,6 +71,10 @@ define([ expect(mockPlugin).toHaveBeenCalledWith(openmct); expect(mockPlugin2).toHaveBeenCalledWith(openmct); }); + + it("emits a start event", function () { + expect(mockListener).toHaveBeenCalled(); + }); }); describe("setAssetPath", function () {