From 8c38ef40bd9b1ff794de218ea71d43971bef4c59 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Sat, 13 Sep 2014 01:19:39 +0200 Subject: delete feed + undo --- .../unit/controller/NavigationControllerSpec.js | 59 ++++++++++++++++++++++ js/tests/unit/service/FeedResourceSpec.js | 26 ++++++---- 2 files changed, 75 insertions(+), 10 deletions(-) (limited to 'js/tests/unit') diff --git a/js/tests/unit/controller/NavigationControllerSpec.js b/js/tests/unit/controller/NavigationControllerSpec.js index d502d99c6..f5781dafa 100644 --- a/js/tests/unit/controller/NavigationControllerSpec.js +++ b/js/tests/unit/controller/NavigationControllerSpec.js @@ -707,4 +707,63 @@ describe('NavigationController', function () { expect(ctrl.renamingFolder).toBe(false); })); + + it('should reversibly delete a feed', inject(function ( + $controller, FeedResource) { + FeedResource.reversiblyDelete = jasmine.createSpy('reversiblyDelete'); + + var ctrl = $controller('NavigationController', { + FeedResource: FeedResource, + }); + + var feed = { + id: 3, + deleted: false + }; + + ctrl.reversiblyDeleteFeed(feed); + + expect(FeedResource.reversiblyDelete).toHaveBeenCalledWith(3); + expect(feed.deleted).toBe(true); + })); + + + it('should undo delete a feed', inject(function ( + $controller, FeedResource) { + FeedResource.undoDelete = jasmine.createSpy('undoDelete'); + + var ctrl = $controller('NavigationController', { + FeedResource: FeedResource, + }); + + var feed = { + id: 3, + deleted: false + }; + + ctrl.undoDeleteFeed(feed); + + expect(FeedResource.undoDelete).toHaveBeenCalledWith(3); + expect(feed.deleted).toBe(false); + })); + + + it('should delete a feed', inject(function ( + $controller, FeedResource) { + FeedResource.delete = jasmine.createSpy('undoDelete'); + + var ctrl = $controller('NavigationController', { + FeedResource: FeedResource, + }); + + var feed = { + id: 3 + }; + + ctrl.deleteFeed(feed); + + expect(FeedResource.delete).toHaveBeenCalledWith(3); + })); + + }); diff --git a/js/tests/unit/service/FeedResourceSpec.js b/js/tests/unit/service/FeedResourceSpec.js index 72bc339d7..c6f3ba050 100644 --- a/js/tests/unit/service/FeedResourceSpec.js +++ b/js/tests/unit/service/FeedResourceSpec.js @@ -113,14 +113,13 @@ describe('FeedResource', function () { - it ('should delete a feed', inject(function (FeedResource) { - http.expectDELETE('base/feeds/1').respond(200, {}); + it ('should reversibly delete a feed', inject(function (FeedResource) { + http.expectDELETE('base/feeds/2').respond(200, {}); - FeedResource.delete('ye'); + FeedResource.reversiblyDelete(2); http.flush(); - expect(FeedResource.size()).toBe(2); })); @@ -211,21 +210,28 @@ describe('FeedResource', function () { })); - it ('should undo a delete folder', inject(function (FeedResource) { - http.expectDELETE('base/feeds/1').respond(200, {}); + it ('should undo a delete feed', inject(function (FeedResource) { + http.expectDELETE('base/feeds/2').respond(200, {}); - FeedResource.delete('ye'); + FeedResource.reversiblyDelete(2); http.flush(); - http.expectPOST('base/feeds/1/restore').respond(200, {}); + http.expectPOST('base/feeds/2/restore').respond(200, {}); - FeedResource.undoDelete(); + FeedResource.undoDelete(2); http.flush(); - expect(FeedResource.get('ye').id).toBe(1); + expect(FeedResource.get('sye').id).toBe(2); + })); + + + it ('should delete a feed', inject(function (FeedResource) { + FeedResource.delete(2); + expect(FeedResource.get('sye')).toBe(undefined); + expect(FeedResource.size()).toBe(2); })); -- cgit v1.2.3