From 53a49a671b027189dd9a9dbd700759908bd4a1bc Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 10 Feb 2016 14:31:56 -0800 Subject: [PATCH] [Create] Test optional filter parameter --- .../test/services/CopyServiceSpec.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/platform/entanglement/test/services/CopyServiceSpec.js b/platform/entanglement/test/services/CopyServiceSpec.js index e1849ec60c..fb5092ba65 100644 --- a/platform/entanglement/test/services/CopyServiceSpec.js +++ b/platform/entanglement/test/services/CopyServiceSpec.js @@ -388,6 +388,7 @@ define( expect(childObjectClone.getModel().location).toEqual(objectClone.getId()); }); }); + describe("when cloning non-creatable objects", function() { beforeEach(function () { policyService.allow.andCallFake(function(category){ @@ -406,6 +407,31 @@ define( .toHaveBeenCalledWith(copiedObject); }); }); + + describe("when provided a filtering function", function () { + function accept() { + return true; + } + function reject() { + return false; + } + + it("does not create new instances of objects " + + "rejected by the filter", function() { + copyService.perform(object, newParent, reject) + .then(copyFinished); + expect(copyFinished.mostRecentCall.args[0]) + .toBe(object); + }); + + it("does create new instances of objects " + + "accepted by the filter", function() { + copyService.perform(object, newParent, accept) + .then(copyFinished); + expect(copyFinished.mostRecentCall.args[0]) + .not.toBe(object); + }); + }); }); describe("on invalid inputs", function () {