Merge branch 'master' into persist-on-mutation-825

Conflicts:
	platform/commonUI/edit/test/actions/EditAndComposeActionSpec.js
This commit is contained in:
Victor Woeltjen
2016-05-20 10:59:54 -07:00
11 changed files with 118 additions and 98 deletions

View File

@@ -21,8 +21,8 @@
*****************************************************************************/
define(
["../../src/actions/LinkAction"],
function (LinkAction) {
["../../src/actions/EditAndComposeAction"],
function (EditAndComposeAction) {
describe("The Link action", function () {
var mockQ,
@@ -30,6 +30,8 @@ define(
mockParent,
mockContext,
mockComposition,
mockActionCapability,
mockEditAction,
mockType,
actionContext,
model,
@@ -65,17 +67,22 @@ define(
};
mockContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockComposition = jasmine.createSpyObj("composition", [ "invoke", "add" ]);
mockType = jasmine.createSpyObj("type", [ "hasFeature" ]);
mockType = jasmine.createSpyObj("type", [ "hasFeature", "getKey" ]);
mockActionCapability = jasmine.createSpyObj("actionCapability", [ "getActions"]);
mockEditAction = jasmine.createSpyObj("editAction", ["perform"]);
mockDomainObject.getId.andReturn("test");
mockDomainObject.getCapability.andReturn(mockContext);
mockContext.getParent.andReturn(mockParent);
mockType.hasFeature.andReturn(true);
mockType.getKey.andReturn("layout");
mockComposition.invoke.andReturn(mockPromise(true));
mockComposition.add.andReturn(mockPromise(true));
mockActionCapability.getActions.andReturn([]);
capabilities = {
composition: mockComposition,
action: mockActionCapability,
type: mockType
};
model = {
@@ -87,7 +94,7 @@ define(
selectedObject: mockDomainObject
};
action = new LinkAction(actionContext);
action = new EditAndComposeAction(actionContext);
});
@@ -97,6 +104,21 @@ define(
.toHaveBeenCalledWith(mockDomainObject);
});
it("enables edit mode for objects that have an edit action", function () {
mockActionCapability.getActions.andReturn([mockEditAction]);
action.perform();
expect(mockEditAction.perform).toHaveBeenCalled();
});
it("Does not enable edit mode for objects that do not have an" +
" edit action", function () {
mockActionCapability.getActions.andReturn([]);
action.perform();
expect(mockEditAction.perform).not.toHaveBeenCalled();
expect(mockComposition.add)
.toHaveBeenCalledWith(mockDomainObject);
});
});
}
);