mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 01:42:31 +00:00
Merge pull request #1132 from nasa/locator-collapse-1008
[Locator] Don't reset root unnecessarily
This commit is contained in:
commit
7998a3fc98
@ -50,10 +50,7 @@ define(
|
||||
$scope.rootObject =
|
||||
(context && context.getRoot()) || $scope.rootObject;
|
||||
}, 0);
|
||||
} else if (!contextRoot) {
|
||||
//If no context root is available, default to the root
|
||||
// object
|
||||
$scope.rootObject = undefined;
|
||||
} else if (!contextRoot && !$scope.rootObject) {
|
||||
// Update the displayed tree on a timeout to avoid
|
||||
// an infinite digest exception.
|
||||
objectService.getObjects(['ROOT'])
|
||||
|
@ -138,23 +138,34 @@ define(
|
||||
});
|
||||
});
|
||||
describe("when no context is available", function () {
|
||||
var defaultRoot = "DEFAULT_ROOT";
|
||||
|
||||
beforeEach(function () {
|
||||
mockContext.getRoot.andReturn(undefined);
|
||||
getObjectsPromise.then.andCallFake(function (callback) {
|
||||
callback({'ROOT': defaultRoot});
|
||||
});
|
||||
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
|
||||
});
|
||||
|
||||
it("provides a default context where none is available", function () {
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
mockTimeout.mostRecentCall.args[0]();
|
||||
expect(mockScope.rootObject).toBe(defaultRoot);
|
||||
var defaultRoot = "DEFAULT_ROOT";
|
||||
|
||||
beforeEach(function () {
|
||||
mockContext.getRoot.andReturn(undefined);
|
||||
getObjectsPromise.then.andCallFake(function (callback) {
|
||||
callback({'ROOT': defaultRoot});
|
||||
});
|
||||
controller = new LocatorController(mockScope, mockTimeout, mockObjectService);
|
||||
});
|
||||
|
||||
it("provides a default context where none is available", function () {
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
mockTimeout.mostRecentCall.args[0]();
|
||||
expect(mockScope.rootObject).toBe(defaultRoot);
|
||||
});
|
||||
|
||||
it("does not issue redundant requests for the root object", function () {
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
mockTimeout.mostRecentCall.args[0]();
|
||||
mockScope.$watch.mostRecentCall.args[1](undefined);
|
||||
mockTimeout.mostRecentCall.args[0]();
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
mockTimeout.mostRecentCall.args[0]();
|
||||
expect(mockObjectService.getObjects.calls.length)
|
||||
.toEqual(1);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user