Merge remote-tracking branch 'upstream/master' into open23

This commit is contained in:
Shivam Dave
2015-06-25 14:08:46 -07:00
29 changed files with 1386 additions and 165 deletions

View File

@@ -31,7 +31,7 @@ define(
mockQ,
mockNavigationService,
mockObject,
mockCapability,
mockType,
controller;
beforeEach(function () {
@@ -48,15 +48,18 @@ define(
"domainObject",
[ "getId", "getModel", "getCapability", "hasCapability" ]
);
mockCapability = jasmine.createSpyObj(
"capability",
[ "invoke" ]
mockType = jasmine.createSpyObj(
"type",
[ "hasFeature" ]
);
mockNavigationService.getNavigation.andReturn(mockObject);
mockObject.getId.andReturn("test");
mockObject.getModel.andReturn({ name: "Test object" });
mockObject.getCapability.andReturn(mockCapability);
mockObject.getCapability.andCallFake(function (key) {
return key === 'type' && mockType;
});
mockType.hasFeature.andReturn(true);
controller = new EditController(
mockScope,
@@ -76,7 +79,7 @@ define(
.toBeDefined();
// Shouldn't have been the mock capability we provided
expect(controller.navigatedObject().getCapability("editor"))
.not.toEqual(mockCapability);
.not.toEqual(mockType);
});
it("detaches its navigation listener when destroyed", function () {
@@ -119,4 +122,4 @@ define(
});
}
);
);

View File

@@ -32,6 +32,7 @@ define(
completionCapability,
object,
mockQ,
mockType,
cache;
@@ -40,10 +41,13 @@ define(
return {
getId: function () { return id; },
getModel: function () { return {}; },
getCapability: function (name) {
return completionCapability;
getCapability: function (key) {
return {
editor: completionCapability,
type: mockType
}[key];
},
hasCapability: function (name) {
hasCapability: function (key) {
return false;
}
};
@@ -62,6 +66,8 @@ define(
beforeEach(function () {
mockQ = jasmine.createSpyObj('$q', ['when', 'all']);
mockType = jasmine.createSpyObj('type', ['hasFeature']);
mockType.hasFeature.andReturn(true);
captured = {};
completionCapability = {
save: function () {
@@ -152,6 +158,17 @@ define(
.toBe(wrappedObject);
});
it("does not wrap non-editable objects", function () {
var domainObject = new TestObject('test-id');
mockType.hasFeature.andCallFake(function (key) {
return key !== 'creation';
});
expect(cache.getEditableObject(domainObject))
.toBe(domainObject);
});
});
}