From 1ea7fa30842dcaa387c9263939d3f1408d23814a Mon Sep 17 00:00:00 2001 From: Alex M Date: Thu, 15 Sep 2016 20:28:29 +0300 Subject: [PATCH] [Edit] SaveAsAction tests cover save and finish --- .../edit/test/actions/SaveAsActionSpec.js | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js index 6bf631feed..a51e165688 100644 --- a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js @@ -19,7 +19,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global describe,it,expect,beforeEach,jasmine*/ +/*global describe,it,expect,beforeEach,jasmine,runs,waitsFor,spyOn*/ define( ["../../src/actions/SaveAsAction"], @@ -78,9 +78,10 @@ define( mockEditorCapability = jasmine.createSpyObj( "editor", - ["save", "isEditContextRoot"] + ["save", "finish", "isEditContextRoot"] ); mockEditorCapability.save.andReturn(mockPromise(true)); + mockEditorCapability.finish.andReturn(mockPromise(true)); mockEditorCapability.isEditContextRoot.andReturn(true); capabilities.editor = mockEditorCapability; @@ -154,6 +155,28 @@ define( mockDomainObject.getModel.andReturn({persisted: 0}); expect(SaveAsAction.appliesTo(actionContext)).toBe(false); }); + + it("uses the editor capability to save the object", function () { + mockEditorCapability.save.andReturn(new Promise(function () {})); + runs(function () { + action.perform(); + }); + waitsFor(function () { + return mockEditorCapability.save.calls.length > 0; + }, "perform() should call EditorCapability.save"); + runs(function () { + expect(mockEditorCapability.finish).not.toHaveBeenCalled(); + }); + }); + + it("uses the editor capability to finish editing the object", function () { + runs(function () { + action.perform(); + }); + waitsFor(function () { + return mockEditorCapability.finish.calls.length > 0; + }, "perform() should call EditorCapability.finish"); + }); it("returns to browse after save", function () { spyOn(action, "save");