summaryrefslogtreecommitdiffstats
path: root/js/tests
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-09-13 01:19:39 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-09-13 01:19:39 +0200
commit8c38ef40bd9b1ff794de218ea71d43971bef4c59 (patch)
tree5547ceda7b7dd350d379073b1cdf7a423e6c7d16 /js/tests
parent72c4fc9acb1380021eb4665af78ef8e26058c86a (diff)
delete feed + undo
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/controller/NavigationControllerSpec.js59
-rw-r--r--js/tests/unit/service/FeedResourceSpec.js26
2 files changed, 75 insertions, 10 deletions
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);
}));