openmct/platform/containment/test/CompositionMutabilityPolicySpec.js
Victor Woeltjen 036722b275 [Containment] Disallow composition in immutable objects
Disallow composition in objects which cannot be created, under
the rationale that creatable objects must also be immutable.
WTD-1098.
2015-04-10 19:24:16 -07:00

26 lines
896 B
JavaScript

/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
define(
["../src/CompositionMutabilityPolicy"],
function (CompositionMutabilityPolicy) {
"use strict";
describe("The composition mutability policy", function () {
var mockType,
policy;
beforeEach(function () {
mockType = jasmine.createSpyObj('type', ['hasFeature']);
policy = new CompositionMutabilityPolicy();
});
it("only allows composition for types which will have a composition capability", function () {
expect(policy.allow(mockType)).toBeFalsy();
mockType.hasFeature.andReturn(true);
expect(policy.allow(mockType)).toBeTruthy();
expect(mockType.hasFeature).toHaveBeenCalledWith('creation');
});
});
}
);