From cc8ba18ccc7a5e0c3627c26a5d2593534eb60f7b Mon Sep 17 00:00:00 2001 From: Joshi Date: Fri, 3 Jan 2020 11:27:06 -0800 Subject: [PATCH] Fixes condition plugin tests --- src/plugins/condition/pluginSpec.js | 83 ++++++++++++++--------------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/src/plugins/condition/pluginSpec.js b/src/plugins/condition/pluginSpec.js index 88f5c002ea..5df6d196dd 100644 --- a/src/plugins/condition/pluginSpec.js +++ b/src/plugins/condition/pluginSpec.js @@ -23,18 +23,51 @@ import { createOpenMct } from "testTools"; import ConditionPlugin from "./plugin"; -let openmct; +let openmct = createOpenMct(); +openmct.install(new ConditionPlugin()); + let conditionDefinition; let conditionSetDefinition; let mockDomainObject; +let mockDomainObject2; +let element; +let child; describe('the plugin', function () { - beforeEach(() => { - openmct = createOpenMct(); - openmct.install(new ConditionPlugin()); + beforeAll((done) => { conditionDefinition = openmct.types.get('condition').definition; + mockDomainObject = { + identifier: { + key: 'testConditionKey', + namespace: '' + }, + type: 'condition' + }; + + conditionDefinition.initialize(mockDomainObject); + conditionSetDefinition = openmct.types.get('conditionSet').definition; + const appHolder = document.createElement('div'); + appHolder.style.width = '640px'; + appHolder.style.height = '480px'; + + element = document.createElement('div'); + child = document.createElement('div'); + element.appendChild(child); + + mockDomainObject2 = { + identifier: { + key: 'testConditionSetKey', + namespace: '' + }, + type: 'conditionSet' + }; + + conditionSetDefinition.initialize(mockDomainObject2); + + openmct.on('start', done); + openmct.start(appHolder); }); let mockConditionObject = { @@ -58,17 +91,6 @@ describe('the plugin', function () { }); describe('the condition object', () => { - beforeEach(() => { - mockDomainObject = { - identifier: { - key: 'testConditionKey', - namespace: '' - }, - type: 'condition' - }; - - conditionDefinition.initialize(mockDomainObject); - }); it('is not creatable', () => { expect(conditionDefinition.creatable).toEqual(mockConditionObject.creatable); @@ -81,39 +103,14 @@ describe('the plugin', function () { }); describe('the conditionSet object', () => { - let element; - let child; - beforeEach((done) => { - const appHolder = document.createElement('div'); - appHolder.style.width = '640px'; - appHolder.style.height = '480px'; - - element = document.createElement('div'); - child = document.createElement('div'); - element.appendChild(child); - - mockDomainObject = { - identifier: { - key: 'testConditionSetKey', - namespace: '' - }, - type: 'conditionSet' - }; - - conditionSetDefinition.initialize(mockDomainObject); - - openmct.on('start', done); - openmct.start(appHolder); - }); - - it('is not creatable', () => { + it('is creatable', () => { expect(conditionSetDefinition.creatable).toEqual(mockConditionSetObject.creatable); }); it('initializes with an empty composition list', () => { - expect(mockDomainObject.composition instanceof Array).toBeTrue(); - expect(mockDomainObject.composition.length).toEqual(0); + expect(mockDomainObject2.composition instanceof Array).toBeTrue(); + expect(mockDomainObject2.composition.length).toEqual(0); }); it('provides a view', () => {