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 () {
|
2018-06-30 00:32:59 +00:00
|
|
|
mockType.getInitialModel.and.returnValue({});
|
2017-03-27 00:02:00 +00:00
|
|
|
expect(policy.allow(mockObject)).toBeFalsy();
|
2018-06-30 00:32:59 +00:00
|
|
|
mockType.getInitialModel.and.returnValue({ composition: [] });
|
2017-03-27 00:02:00 +00:00
|
|
|
expect(policy.allow(mockObject)).toBeTruthy();
|
2015-06-03 20:46:25 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|