[Browse] Test auto-expand fix

Add a test to verify fix for WTD-627 (specifically, verify
that a node does not auto-expand if a selection is made
in some other subtree.)
This commit is contained in:
Victor Woeltjen 2014-12-17 15:41:44 -08:00
parent 4d94ab6fd6
commit 24048024f6

View File

@ -100,6 +100,39 @@ define(
}); });
it("does not expand a node if it is not on the navigation path", function () {
var mockParentContext = jasmine.createSpyObj(
"parentContext",
[ "getParent", "getPath", "getRoot" ]
),
mockChildContext = jasmine.createSpyObj(
"childContext",
[ "getParent", "getPath", "getRoot" ]
),
parent = new TestObject("parent", mockParentContext),
child = new TestObject("child", mockChildContext);
mockChildContext.getParent.andReturn(parent);
mockChildContext.getPath.andReturn([child, child]);
mockParentContext.getPath.andReturn([parent]);
// Set up such that we are on, but not at the end of, a path
mockScope.ngModel = { selectedObject: child };
mockScope.domainObject = parent;
mockScope.toggle = jasmine.createSpyObj("toggle", ["setState"]);
// Invoke the watch with the new selection
mockScope.$watch.calls[0].args[1](child);
// Expansion is tracked on a timeout, because too
// much expansion can result in an unstable digest.
// We want to make sure no timeouts are pending here.
expect(mockTimeout).not.toHaveBeenCalled();
expect(controller.hasBeenExpanded()).toBeFalsy();
expect(controller.isSelected()).toBeFalsy();
});
it("does not expand a node if no context is available", function () { it("does not expand a node if no context is available", function () {
var mockParentContext = jasmine.createSpyObj( var mockParentContext = jasmine.createSpyObj(
"parentContext", "parentContext",