mirror of
https://github.com/nasa/openmct.git
synced 2025-04-19 16:40:58 +00:00
[Edit] Add test case for double-wrapping
Add test case to detect double-wrapping of domain objects retrieved via the editable domain object cache, identified as the root cause of WTD-1071.
This commit is contained in:
parent
3c3dd0ad17
commit
60ed17e32b
@ -21,6 +21,9 @@ define(
|
||||
getModel: function () { return {}; },
|
||||
getCapability: function (name) {
|
||||
return completionCapability;
|
||||
},
|
||||
hasCapability: function (name) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -29,6 +32,9 @@ define(
|
||||
var result = Object.create(domainObject);
|
||||
result.wrapped = true;
|
||||
result.wrappedModel = model;
|
||||
result.hasCapability = function (name) {
|
||||
return name === 'editor';
|
||||
};
|
||||
captured.wraps = (captured.wraps || 0) + 1;
|
||||
return result;
|
||||
}
|
||||
@ -112,6 +118,19 @@ define(
|
||||
expect(cache.isRoot(domainObjects[2])).toBeFalsy();
|
||||
});
|
||||
|
||||
it("does not double-wrap objects", function () {
|
||||
var domainObject = new TestObject('test-id'),
|
||||
wrappedObject = cache.getEditableObject(domainObject);
|
||||
|
||||
// Same instance should be returned if you try to wrap
|
||||
// twice. This is necessary, since it's possible to (e.g.)
|
||||
// use a context capability on an object retrieved via
|
||||
// composition, in which case a result will already be
|
||||
// wrapped.
|
||||
expect(cache.getEditableObject(wrappedObject))
|
||||
.toBe(wrappedObject);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user