[Create] Test creation filtering

Test that only types which indicate they should be createable
appear in the Create menu. WTD-705.
This commit is contained in:
Victor Woeltjen 2015-01-21 16:24:13 -08:00
parent b4679b9c6d
commit f12d0ab313

View File

@ -12,6 +12,7 @@ define(
var mockTypeService,
mockDialogService,
mockCreationService,
mockTypes,
provider;
function createMockType(name) {
@ -23,9 +24,11 @@ define(
"getName",
"getDescription",
"getProperties",
"getInitialModel"
"getInitialModel",
"hasFeature"
]
);
mockType.hasFeature.andReturn(true);
mockType.getName.andReturn(name);
return mockType;
}
@ -43,10 +46,9 @@ define(
"creationService",
[ "createObject" ]
);
mockTypes = [ "A", "B", "C" ].map(createMockType);
mockTypeService.listTypes.andReturn(
[ "A", "B", "C" ].map(createMockType)
);
mockTypeService.listTypes.andReturn(mockTypes);
provider = new CreateActionProvider(
mockTypeService,
@ -68,6 +70,19 @@ define(
domainObject: {}
}).length).toEqual(0);
});
it("does not expose non-creatable types", function () {
// One of the types won't have the creation feature...
mockTypes[1].hasFeature.andReturn(false);
// ...so it should have been filtered out.
expect(provider.getActions({
key: "create",
domainObject: {}
}).length).toEqual(2);
// Make sure it was creation which was used to check
expect(mockTypes[1].hasFeature)
.toHaveBeenCalledWith("creation");
});
});
}
);