mirror of
https://github.com/nasa/openmct.git
synced 2025-06-05 00:50:49 +00:00
[Tree] Test inner tree creation
This commit is contained in:
parent
8f94751a35
commit
d72aaf54ca
@ -99,9 +99,25 @@ define([
|
|||||||
describe("model", function () {
|
describe("model", function () {
|
||||||
var mockComposition;
|
var mockComposition;
|
||||||
|
|
||||||
|
function makeGenericCapabilities() {
|
||||||
|
var mockContext =
|
||||||
|
jasmine.createSpyObj('context', [ 'getPath' ]),
|
||||||
|
mockType =
|
||||||
|
jasmine.createSpyObj('type', [ 'getGlyph' ]),
|
||||||
|
mockLocation =
|
||||||
|
jasmine.createSpyObj('location', [ 'isLink' ]),
|
||||||
|
mockMutation =
|
||||||
|
jasmine.createSpyObj('mutation', [ 'listen' ]);
|
||||||
|
return {
|
||||||
|
context: mockContext,
|
||||||
|
type: mockType,
|
||||||
|
mutation: mockMutation,
|
||||||
|
location: mockLocation
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function waitForCompositionCallback() {
|
function waitForCompositionCallback() {
|
||||||
var calledBack = false,
|
var calledBack = false;
|
||||||
n = Math.random();
|
|
||||||
testCapabilities.composition.invoke().then(function (c) {
|
testCapabilities.composition.invoke().then(function (c) {
|
||||||
calledBack = true;
|
calledBack = true;
|
||||||
});
|
});
|
||||||
@ -112,22 +128,11 @@ define([
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockComposition = ['a', 'b', 'c'].map(function (id) {
|
mockComposition = ['a', 'b', 'c'].map(function (id) {
|
||||||
var mockContext =
|
var testCapabilities = makeGenericCapabilities(),
|
||||||
jasmine.createSpyObj('context', [ 'getPath' ]),
|
mockChild =
|
||||||
mockType =
|
makeMockDomainObject(id, {}, testCapabilities);
|
||||||
jasmine.createSpyObj('type', [ 'getGlyph' ]),
|
|
||||||
mockLocation =
|
|
||||||
jasmine.createSpyObj('location', [ 'isLink' ]),
|
|
||||||
mockMutation =
|
|
||||||
jasmine.createSpyObj('mutation', [ 'listen' ]),
|
|
||||||
mockChild = makeMockDomainObject(id, {}, {
|
|
||||||
context: mockContext,
|
|
||||||
type: mockType,
|
|
||||||
mutation: mockMutation,
|
|
||||||
location: mockLocation
|
|
||||||
});
|
|
||||||
|
|
||||||
mockContext.getPath
|
testCapabilities.context.getPath
|
||||||
.andReturn([mockDomainObject, mockChild]);
|
.andReturn([mockDomainObject, mockChild]);
|
||||||
|
|
||||||
return mockChild;
|
return mockChild;
|
||||||
@ -194,6 +199,54 @@ define([
|
|||||||
expect(selected.length).toEqual(1);
|
expect(selected.length).toEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("when children contain children", function () {
|
||||||
|
beforeEach(function () {
|
||||||
|
var newCapabilities = makeGenericCapabilities(),
|
||||||
|
gcCapabilities = makeGenericCapabilities(),
|
||||||
|
mockNewChild =
|
||||||
|
makeMockDomainObject('d', {}, newCapabilities),
|
||||||
|
mockGrandchild =
|
||||||
|
makeMockDomainObject('gc', {}, gcCapabilities),
|
||||||
|
calledBackInner = false;
|
||||||
|
|
||||||
|
newCapabilities.composition =
|
||||||
|
jasmine.createSpyObj('composition', [ 'invoke' ]);
|
||||||
|
newCapabilities.composition.invoke
|
||||||
|
.andReturn(Promise.resolve([mockGrandchild]));
|
||||||
|
mockComposition.push(mockNewChild);
|
||||||
|
|
||||||
|
newCapabilities.context.getPath.andReturn([
|
||||||
|
mockDomainObject,
|
||||||
|
mockNewChild
|
||||||
|
]);
|
||||||
|
gcCapabilities.context.getPath.andReturn([
|
||||||
|
mockDomainObject,
|
||||||
|
mockNewChild,
|
||||||
|
mockGrandchild
|
||||||
|
]);
|
||||||
|
|
||||||
|
testCapabilities.mutation.listen
|
||||||
|
.mostRecentCall.args[0](mockDomainObject);
|
||||||
|
waitForCompositionCallback();
|
||||||
|
runs(function () {
|
||||||
|
// Select the innermost object to force expansion,
|
||||||
|
// such that we can verify the subtree is present.
|
||||||
|
treeView.value(mockGrandchild);
|
||||||
|
newCapabilities.composition.invoke().then(function () {
|
||||||
|
calledBackInner = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
waitsFor(function () {
|
||||||
|
return calledBackInner;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("creates inner trees", function () {
|
||||||
|
expect($(treeView.elements()[0]).find('ul').length)
|
||||||
|
.toEqual(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("observe", function () {
|
describe("observe", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user