mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 07:38:15 +00:00
[Layout] Update specs
Update specs to reflect changes made to the manner in which a view may persist view configuration changes, for WTD-535.
This commit is contained in:
@ -67,7 +67,7 @@ define(
|
|||||||
|
|
||||||
// Respond to the destruction of the current representation.
|
// Respond to the destruction of the current representation.
|
||||||
function destroy() {
|
function destroy() {
|
||||||
// No op
|
// Nothing to clean up
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle a specific representation of a specific domain object
|
// Handle a specific representation of a specific domain object
|
||||||
|
@ -7,6 +7,7 @@ define(
|
|||||||
|
|
||||||
describe("The Edit mode representer", function () {
|
describe("The Edit mode representer", function () {
|
||||||
var mockQ,
|
var mockQ,
|
||||||
|
mockLog,
|
||||||
mockScope,
|
mockScope,
|
||||||
testRepresentation,
|
testRepresentation,
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
@ -23,6 +24,7 @@ define(
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockQ = { when: mockPromise };
|
mockQ = { when: mockPromise };
|
||||||
|
mockLog = jasmine.createSpyObj("$log", ["info", "debug"]);
|
||||||
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
|
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
|
||||||
testRepresentation = { key: "test" };
|
testRepresentation = { key: "test" };
|
||||||
mockDomainObject = jasmine.createSpyObj("domainObject", [
|
mockDomainObject = jasmine.createSpyObj("domainObject", [
|
||||||
@ -35,39 +37,24 @@ define(
|
|||||||
mockPersistence =
|
mockPersistence =
|
||||||
jasmine.createSpyObj("persistence", ["persist"]);
|
jasmine.createSpyObj("persistence", ["persist"]);
|
||||||
|
|
||||||
|
mockDomainObject.getModel.andReturn({});
|
||||||
mockDomainObject.hasCapability.andReturn(true);
|
mockDomainObject.hasCapability.andReturn(true);
|
||||||
mockDomainObject.useCapability.andReturn(true);
|
mockDomainObject.useCapability.andReturn(true);
|
||||||
mockDomainObject.getCapability.andReturn(mockPersistence);
|
mockDomainObject.getCapability.andReturn(mockPersistence);
|
||||||
|
|
||||||
representer = new EditRepresenter(mockQ, mockScope);
|
representer = new EditRepresenter(mockQ, mockLog, mockScope);
|
||||||
representer.represent(testRepresentation, mockDomainObject);
|
representer.represent(testRepresentation, mockDomainObject);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("watches for changes in view configuration", function () {
|
it("provides a commit method in scope", function () {
|
||||||
// Should watch the configuration field,
|
expect(mockScope.commit).toEqual(jasmine.any(Function));
|
||||||
// provided by mct-representation
|
|
||||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
|
||||||
"configuration",
|
|
||||||
jasmine.any(Function),
|
|
||||||
true // should be a deep watch
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("watches for changes in domain object model", function () {
|
|
||||||
// Should watch the model field,
|
|
||||||
// provided by mct-representation
|
|
||||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
|
||||||
"model",
|
|
||||||
jasmine.any(Function),
|
|
||||||
true // should be a deep watch
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("mutates and persists upon observed changes", function () {
|
it("mutates and persists upon observed changes", function () {
|
||||||
mockScope.model = { someKey: "some value" };
|
mockScope.model = { someKey: "some value" };
|
||||||
mockScope.configuration = { someConfiguration: "something" };
|
mockScope.configuration = { someConfiguration: "something" };
|
||||||
|
|
||||||
mockScope.$watch.mostRecentCall.args[1].call();
|
mockScope.commit("Some message");
|
||||||
|
|
||||||
// Should have mutated the object...
|
// Should have mutated the object...
|
||||||
expect(mockDomainObject.useCapability).toHaveBeenCalledWith(
|
expect(mockDomainObject.useCapability).toHaveBeenCalledWith(
|
||||||
|
@ -91,6 +91,25 @@ define(
|
|||||||
// that a configuration for b has been defined.
|
// that a configuration for b has been defined.
|
||||||
expect(testConfiguration.panels.b).toBeDefined();
|
expect(testConfiguration.panels.b).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it("invokes commit after drag", function () {
|
||||||
|
// Populate scope
|
||||||
|
mockScope.$watch.mostRecentCall.args[1](testModel);
|
||||||
|
|
||||||
|
// Add a commit method to scope
|
||||||
|
mockScope.commit = jasmine.createSpy("commit");
|
||||||
|
|
||||||
|
// Do a drag
|
||||||
|
controller.startDrag("b", [1, 1], [0, 0]);
|
||||||
|
controller.continueDrag([100, 100]);
|
||||||
|
controller.endDrag();
|
||||||
|
|
||||||
|
// Should have triggered commit (provided by
|
||||||
|
// EditRepresenter) with some message.
|
||||||
|
expect(mockScope.commit)
|
||||||
|
.toHaveBeenCalledWith(jasmine.any(String));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
Reference in New Issue
Block a user