From 41e248a2c533a638365c5d8996fc0dbc5be97b92 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 18 Mar 2015 12:36:51 -0700 Subject: [PATCH] [Edit] Add test cases Add test cases for changes to Edit mode capability wrappers which reduce scope of Create menu's Save in to the object being edited, for WTD-922. --- .../capabilities/EditableContextCapabilitySpec.js | 12 ++++++++++++ .../test/objects/EditableDomainObjectCacheSpec.js | 11 +++++++++++ 2 files changed, 23 insertions(+) diff --git a/platform/commonUI/edit/test/capabilities/EditableContextCapabilitySpec.js b/platform/commonUI/edit/test/capabilities/EditableContextCapabilitySpec.js index 0ba6160601..7994058838 100644 --- a/platform/commonUI/edit/test/capabilities/EditableContextCapabilitySpec.js +++ b/platform/commonUI/edit/test/capabilities/EditableContextCapabilitySpec.js @@ -51,6 +51,18 @@ define( expect(mockContext.getDomainObject.calls.length).toEqual(1); }); + it("hides the root object", function () { + expect(capability.getRoot()).toEqual(mockEditableObject); + expect(capability.getPath()).toEqual([mockEditableObject]); + }); + + it("exposes the root object through a different method", function () { + // Should still go through the factory... + expect(capability.getTrueRoot()).toEqual(someValue); + // ...with value of the unwrapped capability's getRoot + expect(mockFactory.getEditableObject) + .toHaveBeenCalledWith(mockTestObject); + }); }); } ); \ No newline at end of file diff --git a/platform/commonUI/edit/test/objects/EditableDomainObjectCacheSpec.js b/platform/commonUI/edit/test/objects/EditableDomainObjectCacheSpec.js index bdc8cd0d3f..5e71368553 100644 --- a/platform/commonUI/edit/test/objects/EditableDomainObjectCacheSpec.js +++ b/platform/commonUI/edit/test/objects/EditableDomainObjectCacheSpec.js @@ -99,6 +99,17 @@ define( expect(captured.saved).toEqual(1); }); + it("tracks the root object of the Edit mode subgraph", function () { + // Root object is the first object exposed to the cache + var domainObjects = ['a', 'b', 'c'].map(TestObject); + domainObjects.forEach(function (obj) { + cache.getEditableObject(obj); + }); + expect(cache.isRoot(domainObjects[0])).toBeTruthy(); + expect(cache.isRoot(domainObjects[1])).toBeFalsy(); + expect(cache.isRoot(domainObjects[2])).toBeFalsy(); + }); + }); }