mirror of
https://github.com/nasa/openmct.git
synced 2025-06-16 14:18:16 +00:00
[Core] Remove dependency
Remove dependency from the mutation capability; it recognizes and handles promises internally, instead. WTD-931.
This commit is contained in:
@ -151,8 +151,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "mutation",
|
"key": "mutation",
|
||||||
"implementation": "capabilities/MutationCapability.js",
|
"implementation": "capabilities/MutationCapability.js"
|
||||||
"depends": [ "$q" ]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "delegation",
|
"key": "delegation",
|
||||||
|
@ -46,12 +46,11 @@ define(
|
|||||||
* });
|
* });
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* @param $q Angular's $q service, for promises
|
|
||||||
* @param {DomainObject} domainObject the domain object
|
* @param {DomainObject} domainObject the domain object
|
||||||
* which will expose this capability
|
* which will expose this capability
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function MutationCapability($q, domainObject) {
|
function MutationCapability(domainObject) {
|
||||||
|
|
||||||
function mutate(mutator) {
|
function mutate(mutator) {
|
||||||
// Get the object's model and clone it, so the
|
// Get the object's model and clone it, so the
|
||||||
|
@ -13,21 +13,9 @@ define(
|
|||||||
domainObject = { getModel: function () { return testModel; } },
|
domainObject = { getModel: function () { return testModel; } },
|
||||||
mutation;
|
mutation;
|
||||||
|
|
||||||
function mockPromise(value) {
|
|
||||||
return {
|
|
||||||
then: function (callback) {
|
|
||||||
return (value && value.then) ?
|
|
||||||
value : mockPromise(callback(value));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
testModel = { number: 6 };
|
testModel = { number: 6 };
|
||||||
mutation = new MutationCapability(
|
mutation = new MutationCapability(domainObject);
|
||||||
{ when: mockPromise }, // $q
|
|
||||||
domainObject
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows mutation of a model", function () {
|
it("allows mutation of a model", function () {
|
||||||
|
Reference in New Issue
Block a user