-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef0c830
commit af9d201
Showing
1 changed file
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
/***************************************************************************** | ||
* Open MCT, Copyright (c) 2014-2021, United States Government | ||
* as represented by the Administrator of the National Aeronautics and Space | ||
* Administration. All rights reserved. | ||
* | ||
* Open MCT is licensed under the Apache License, Version 2.0 (the | ||
* 'License'); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* Open MCT includes source code licensed under additional open source | ||
* licenses. See the Open Source Licenses file (LICENSES.md) included with | ||
* this source code distribution or the Licensing information page available | ||
* at runtime from the About dialog for additional information. | ||
*****************************************************************************/ | ||
|
||
import { createOpenMct, resetApplicationState } from 'utils/testing'; | ||
import TabsPlugin from './plugin'; | ||
|
||
import Vue from 'vue'; | ||
|
||
let openmct; | ||
let tabsPlugin; | ||
let tabDefinition | ||
let element; | ||
let child; | ||
let appHolder; | ||
|
||
const testTelemetryObject1 = { | ||
identifier: { | ||
namespace: '', | ||
key: 'test-object-1' | ||
}, | ||
type: 'table', | ||
name: 'Test Object', | ||
location: 'tab-domain-object', | ||
telemetry: { | ||
values: [{ | ||
key: 'utc', | ||
format: 'utc', | ||
name: 'Time', | ||
hints: { | ||
domain: 1 | ||
} | ||
}, { | ||
key: 'some-key', | ||
name: 'Some attribute', | ||
hints: { | ||
range: 1 | ||
} | ||
}] | ||
} | ||
}; | ||
|
||
const tabsDomainObject = { | ||
identifier: { | ||
key: 'tab-domain-object', | ||
namespace: '' | ||
}, | ||
name: 'tabs-test', | ||
currentTabIndex: 0, | ||
type: 'tabs', | ||
composition: [testTelemetryObject1.identifier], | ||
keep_alive: false | ||
}; | ||
|
||
describe('Tabs plugin:', () => { | ||
beforeAll(done => { | ||
appHolder = document.createElement('div'); | ||
appHolder.style.width = '640px'; | ||
appHolder.style.height = '480px'; | ||
|
||
openmct = createOpenMct(); | ||
|
||
element = document.createElement('div'); | ||
child = document.createElement('div'); | ||
element.appendChild(child); | ||
|
||
tabsPlugin = new TabsPlugin(); | ||
openmct.install(tabsPlugin); | ||
|
||
const tableDefinition = openmct.types.get('table').definition; | ||
tableDefinition.initialize(testTelemetryObject1); | ||
|
||
tabDefinition = openmct.types.get('tabs').definition; | ||
tabDefinition.initialize(tabsDomainObject); | ||
|
||
openmct.on('start', done); | ||
openmct.start(appHolder); | ||
|
||
document.body.append(appHolder); | ||
}); | ||
|
||
afterAll(() => { | ||
appHolder.remove(); | ||
resetApplicationState(openmct); | ||
}); | ||
|
||
it('has type as tabs', () => { | ||
expect(tabDefinition.name).toEqual('Tabs View'); | ||
}); | ||
|
||
it('is creatable', () => { | ||
expect(tabDefinition.creatable).toEqual(true); | ||
}); | ||
|
||
describe('Tabs view:', () => { | ||
let tabsViewProvider; | ||
let tabsView; | ||
|
||
beforeEach(() => { | ||
const tabsViewObject = { | ||
...tabsDomainObject, | ||
id: 'test-object', | ||
name: 'tabs' | ||
}; | ||
|
||
const tabsObject = { | ||
name: 'tabs View', | ||
key: 'tabs', | ||
creatable: true | ||
}; | ||
|
||
const applicableViews = openmct.objectViews.get(tabsViewObject, []); | ||
|
||
tabsViewProvider = applicableViews.find(viewProvider => viewProvider.key === tabsObject.key); | ||
tabsView = tabsViewProvider.view(tabsViewObject); | ||
|
||
tabsView.show(child); | ||
|
||
return Vue.nextTick(); | ||
}); | ||
|
||
afterEach(() => { | ||
tabsView.destroy(); | ||
}); | ||
|
||
it('provides tabs view', () => { | ||
expect(tabsViewProvider).toBeDefined(); | ||
}); | ||
|
||
it('renders tab element', () => { | ||
const tabsElements = element.querySelectorAll('.c-tabs'); | ||
|
||
expect(tabsElements.length).toBe(1); | ||
}); | ||
|
||
it('renders empty tab element with msg', () => { | ||
const tabsElement = element.querySelector('.c-tabs'); | ||
|
||
expect(tabsElement.innerText.trim()).toEqual('Drag objects here to add them to this view.'); | ||
}); | ||
}); | ||
}); |