mirror of
https://github.com/nasa/openmct.git
synced 2025-04-08 03:44:24 +00:00
[Tree] Begin testing selection change
This commit is contained in:
parent
ecb37c54be
commit
8b51ae32d2
@ -22,8 +22,9 @@
|
||||
/*global define,describe,beforeEach,jasmine,it,expect*/
|
||||
|
||||
define([
|
||||
'../../src/ui/TreeView'
|
||||
], function (TreeView) {
|
||||
'../../src/ui/TreeView',
|
||||
'zepto'
|
||||
], function (TreeView, $) {
|
||||
'use strict';
|
||||
|
||||
describe("TreeView", function () {
|
||||
@ -62,6 +63,7 @@ define([
|
||||
|
||||
testCapabilities = { mutation: mockMutation };
|
||||
|
||||
mockDomainObject.getId.andReturn('parent');
|
||||
mockDomainObject.hasCapability.andCallFake(function (c) {
|
||||
return !!(testCapabilities[c]);
|
||||
});
|
||||
@ -103,19 +105,28 @@ define([
|
||||
|
||||
beforeEach(function () {
|
||||
mockComposition = ['a', 'b', 'c'].map(function (id) {
|
||||
var mockDomainObject = jasmine.createSpyObj(
|
||||
'domainObject-' + id,
|
||||
[
|
||||
'getId',
|
||||
'getModel',
|
||||
'getCapability',
|
||||
'hasCapability',
|
||||
'useCapability'
|
||||
]
|
||||
);
|
||||
mockDomainObject.getId.andReturn(id);
|
||||
mockDomainObject.getModel.andReturn({});
|
||||
return mockDomainObject;
|
||||
var mockChild = jasmine.createSpyObj(
|
||||
'domainObject-' + id,
|
||||
[
|
||||
'getId',
|
||||
'getModel',
|
||||
'getCapability',
|
||||
'hasCapability',
|
||||
'useCapability'
|
||||
]
|
||||
),
|
||||
mockContext = jasmine.createSpyObj(
|
||||
'context',
|
||||
[ 'getPath' ]
|
||||
);
|
||||
mockChild.getId.andReturn(id);
|
||||
mockChild.getModel.andReturn({});
|
||||
mockChild.getCapability.andCallFake(function (c) {
|
||||
return c === 'context' && mockContext;
|
||||
});
|
||||
mockContext.getPath
|
||||
.andReturn([mockDomainObject, mockChild]);
|
||||
return mockChild;
|
||||
});
|
||||
|
||||
testCapabilities.composition = jasmine.createSpyObj(
|
||||
@ -168,6 +179,19 @@ define([
|
||||
.toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when selection state changes", function () {
|
||||
var selectionIndex = 1;
|
||||
|
||||
beforeEach(function () {
|
||||
treeView.value(mockComposition[selectionIndex]);
|
||||
});
|
||||
|
||||
it("communicates selection state to an appropriate node", function () {
|
||||
var selected = $(treeView.elements()[0]).find('.selected');
|
||||
expect(selected.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("observe", function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user