mirror of
https://github.com/nasa/openmct.git
synced 2025-06-10 03:11:39 +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*/
|
/*global define,describe,beforeEach,jasmine,it,expect*/
|
||||||
|
|
||||||
define([
|
define([
|
||||||
'../../src/ui/TreeView'
|
'../../src/ui/TreeView',
|
||||||
], function (TreeView) {
|
'zepto'
|
||||||
|
], function (TreeView, $) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe("TreeView", function () {
|
describe("TreeView", function () {
|
||||||
@ -62,6 +63,7 @@ define([
|
|||||||
|
|
||||||
testCapabilities = { mutation: mockMutation };
|
testCapabilities = { mutation: mockMutation };
|
||||||
|
|
||||||
|
mockDomainObject.getId.andReturn('parent');
|
||||||
mockDomainObject.hasCapability.andCallFake(function (c) {
|
mockDomainObject.hasCapability.andCallFake(function (c) {
|
||||||
return !!(testCapabilities[c]);
|
return !!(testCapabilities[c]);
|
||||||
});
|
});
|
||||||
@ -103,19 +105,28 @@ define([
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockComposition = ['a', 'b', 'c'].map(function (id) {
|
mockComposition = ['a', 'b', 'c'].map(function (id) {
|
||||||
var mockDomainObject = jasmine.createSpyObj(
|
var mockChild = jasmine.createSpyObj(
|
||||||
'domainObject-' + id,
|
'domainObject-' + id,
|
||||||
[
|
[
|
||||||
'getId',
|
'getId',
|
||||||
'getModel',
|
'getModel',
|
||||||
'getCapability',
|
'getCapability',
|
||||||
'hasCapability',
|
'hasCapability',
|
||||||
'useCapability'
|
'useCapability'
|
||||||
]
|
]
|
||||||
);
|
),
|
||||||
mockDomainObject.getId.andReturn(id);
|
mockContext = jasmine.createSpyObj(
|
||||||
mockDomainObject.getModel.andReturn({});
|
'context',
|
||||||
return mockDomainObject;
|
[ '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(
|
testCapabilities.composition = jasmine.createSpyObj(
|
||||||
@ -168,6 +179,19 @@ define([
|
|||||||
.toEqual(0);
|
.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 () {
|
describe("observe", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user