2015-06-03 20:46:25 +00:00
|
|
|
|
|
|
|
define(
|
|
|
|
["../src/CompositionModelPolicy"],
|
|
|
|
function (CompositionModelPolicy) {
|
|
|
|
|
|
|
|
describe("The composition model policy", function () {
|
2017-03-27 00:02:00 +00:00
|
|
|
var mockObject,
|
|
|
|
mockType,
|
2015-06-03 20:46:25 +00:00
|
|
|
policy;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
mockType = jasmine.createSpyObj('type', ['getInitialModel']);
|
2017-03-27 00:02:00 +00:00
|
|
|
mockObject = {
|
|
|
|
getCapability: function () {
|
|
|
|
return mockType;
|
|
|
|
}
|
|
|
|
};
|
2015-06-03 20:46:25 +00:00
|
|
|
policy = new CompositionModelPolicy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("only allows composition for types which will have a composition property", function () {
|
|
|
|
mockType.getInitialModel.andReturn({});
|
2017-03-27 00:02:00 +00:00
|
|
|
expect(policy.allow(mockObject)).toBeFalsy();
|
2015-06-03 20:46:25 +00:00
|
|
|
mockType.getInitialModel.andReturn({ composition: [] });
|
2017-03-27 00:02:00 +00:00
|
|
|
expect(policy.allow(mockObject)).toBeTruthy();
|
2015-06-03 20:46:25 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|