[Edit] SaveAsAction tests cover save and finish
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
* this source code distribution or the Licensing information page available
|
* this source code distribution or the Licensing information page available
|
||||||
* at runtime from the About dialog for additional information.
|
* 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(
|
define(
|
||||||
["../../src/actions/SaveAsAction"],
|
["../../src/actions/SaveAsAction"],
|
||||||
@@ -78,9 +78,10 @@ define(
|
|||||||
|
|
||||||
mockEditorCapability = jasmine.createSpyObj(
|
mockEditorCapability = jasmine.createSpyObj(
|
||||||
"editor",
|
"editor",
|
||||||
["save", "isEditContextRoot"]
|
["save", "finish", "isEditContextRoot"]
|
||||||
);
|
);
|
||||||
mockEditorCapability.save.andReturn(mockPromise(true));
|
mockEditorCapability.save.andReturn(mockPromise(true));
|
||||||
|
mockEditorCapability.finish.andReturn(mockPromise(true));
|
||||||
mockEditorCapability.isEditContextRoot.andReturn(true);
|
mockEditorCapability.isEditContextRoot.andReturn(true);
|
||||||
capabilities.editor = mockEditorCapability;
|
capabilities.editor = mockEditorCapability;
|
||||||
|
|
||||||
@@ -155,6 +156,28 @@ define(
|
|||||||
expect(SaveAsAction.appliesTo(actionContext)).toBe(false);
|
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 () {
|
it("returns to browse after save", function () {
|
||||||
spyOn(action, "save");
|
spyOn(action, "save");
|
||||||
action.save.andReturn(mockPromise(mockDomainObject));
|
action.save.andReturn(mockPromise(mockDomainObject));
|
||||||
|
|||||||
Reference in New Issue
Block a user