mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 15:18:12 +00:00
[Edit] Avoid extra commits
Avoid issuing extra commit calls from the Edit toolbar; this can cause disruption of state from other views (such as Fixed Position), WTD-881.
This commit is contained in:
@ -91,6 +91,32 @@ define(
|
||||
|
||||
// Should have updated the original object
|
||||
expect(testObject.k).toEqual(456);
|
||||
|
||||
// Should have committed the change
|
||||
expect(mockScope.commit).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not commit if nothing changed", function () {
|
||||
var testObject = { k: 123 };
|
||||
|
||||
// Provide a view which has a toolbar
|
||||
representer.represent({
|
||||
toolbar: { sections: [ { items: [ { property: 'k' } ] } ] }
|
||||
});
|
||||
|
||||
// Update the selection
|
||||
mockScope.selection.push(testObject);
|
||||
expect(mockScope.$watchCollection.mostRecentCall.args[0])
|
||||
.toEqual('selection'); // Make sure we're using right watch
|
||||
mockScope.$watchCollection.mostRecentCall.args[1]([testObject]);
|
||||
|
||||
// Invoke the first watch (assumed to be for toolbar state)
|
||||
mockScope.$watchCollection.calls[0].args[1](
|
||||
mockScope.$parent.testToolbar.state
|
||||
);
|
||||
|
||||
// Should have committed the change
|
||||
expect(mockScope.commit).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user