Skip to content

Commit b48dd4b

Browse files
committed
[Testing] Test start event on MCT
1 parent 35c457b commit b48dd4b

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/MCTSpec.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,46 @@
2222

2323
define([
2424
'./MCT',
25-
'./plugins/plugins'
26-
], function (MCT, plugins) {
25+
'./plugins/plugins',
26+
'legacyRegistry'
27+
], function (MCT, plugins, legacyRegistry) {
2728
describe("MCT", function () {
2829
var openmct;
2930
var mockPlugin;
3031
var mockPlugin2;
32+
var mockListener;
33+
var oldBundles;
3134

3235
beforeEach(function () {
3336
mockPlugin = jasmine.createSpy('plugin');
34-
mockPlugin2 = jasmine.createSpy('plugin');
37+
mockPlugin2 = jasmine.createSpy('plugin2');
38+
mockListener = jasmine.createSpy('listener');
39+
oldBundles = legacyRegistry.list();
3540

3641
openmct = new MCT();
3742

3843
openmct.install(mockPlugin);
3944
openmct.install(mockPlugin2);
45+
openmct.on('start', mockListener);
46+
});
47+
48+
// Clean up the dirty singleton.
49+
afterEach(function () {
50+
legacyRegistry.list().forEach(function (bundle) {
51+
if (oldBundles.indexOf(bundle) === -1) {
52+
legacyRegistry.delete(bundle);
53+
}
54+
});
4055
});
4156

4257
it("exposes plugins", function () {
4358
expect(openmct.plugins).toEqual(plugins);
4459
});
4560

61+
it("does not issue a start event before started", function () {
62+
expect(mockListener).not.toHaveBeenCalled();
63+
});
64+
4665
describe("start", function () {
4766
beforeEach(function () {
4867
openmct.start();
@@ -52,6 +71,10 @@ define([
5271
expect(mockPlugin).toHaveBeenCalledWith(openmct);
5372
expect(mockPlugin2).toHaveBeenCalledWith(openmct);
5473
});
74+
75+
it("emits a start event", function () {
76+
expect(mockListener).toHaveBeenCalled();
77+
});
5578
});
5679

5780
describe("setAssetPath", function () {

0 commit comments

Comments
 (0)