mirror of
https://github.com/nasa/openmct.git
synced 2025-06-17 14:48:13 +00:00
[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.
This commit is contained in:
26
platform/containment/test/CompositionMutabilityPolicySpec.js
Normal file
26
platform/containment/test/CompositionMutabilityPolicySpec.js
Normal file
@ -0,0 +1,26 @@
|
||||
/*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');
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user