summaryrefslogtreecommitdiffstats
path: root/js/tests/unit/service/FeedResourceSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/tests/unit/service/FeedResourceSpec.js')
-rw-r--r--js/tests/unit/service/FeedResourceSpec.js103
1 files changed, 100 insertions, 3 deletions
diff --git a/js/tests/unit/service/FeedResourceSpec.js b/js/tests/unit/service/FeedResourceSpec.js
index 5187435f0..a37ff42f3 100644
--- a/js/tests/unit/service/FeedResourceSpec.js
+++ b/js/tests/unit/service/FeedResourceSpec.js
@@ -10,19 +10,21 @@
describe('FeedResource', () => {
'use strict';
- let resource;
+ let resource,
+ http;
beforeEach(module('News', ($provide) => {
$provide.value('BASE_URL', 'base');
}));
- beforeEach(inject((FeedResource) => {
+ beforeEach(inject((FeedResource, $httpBackend) => {
resource = FeedResource;
+ http = $httpBackend;
FeedResource.receive([
{id: 1, folderId: 3, url: 'ye', unreadCount: 45},
{id: 2, folderId: 4, url: 'sye', unreadCount: 25},
- {id: 3, folderId: 3, url: '1sye', unreadCount: 0}
+ {id: 3, folderId: 3, title: 'hore', url: '1sye', unreadCount: 0}
]);
}));
@@ -104,4 +106,99 @@ describe('FeedResource', () => {
expect(FeedResource.getUnreadCount()).toBe(68);
}));
+
+
+ it ('should delete a feed', inject((FeedResource) => {
+ http.expectDELETE('base/feeds/1').respond(200, {});
+
+ FeedResource.delete('ye');
+
+ http.flush();
+
+ expect(FeedResource.size()).toBe(2);
+ }));
+
+
+ it ('should rename a feed', inject((FeedResource) => {
+ http.expectPOST('base/feeds/3/rename', {
+ feedTitle: 'heho'
+ }).respond(200, {});
+
+ FeedResource.rename('1sye', 'heho');
+
+ http.flush();
+
+ expect(FeedResource.get('1sye').title).toBe('heho');
+ }));
+
+
+ it ('should move a feed', inject((FeedResource) => {
+ http.expectPOST('base/feeds/3/move', {
+ parentFolderId: 5
+ }).respond(200, {});
+
+ FeedResource.move('1sye', 5);
+
+ http.flush();
+
+ expect(FeedResource.get('1sye').folderId).toBe(5);
+ }));
+
+
+ it ('should create a feed', inject((FeedResource) => {
+ http.expectPOST('base/feeds', {
+ parentFolderId: 5,
+ url: 'hey',
+ title: 'ABC'
+ }).respond(200, {});
+
+ FeedResource.create('hey', 5, 'abc');
+
+ http.flush();
+
+ expect(FeedResource.get('hey').folderId).toBe(5);
+ }));
+
+
+ it ('should not create a feed if it exists', inject((FeedResource) => {
+ http.expectPOST('base/feeds', {
+ parentFolderId: 5,
+ url: 'ye',
+ title: 'ABC'
+ }).respond(200, {});
+
+ FeedResource.create('ye', 5, 'abc');
+
+ http.flush();
+
+ expect(FeedResource.size()).toBe(3);
+ }));
+
+
+ it ('should undo a delete folder', inject((FeedResource) => {
+ http.expectDELETE('base/feeds/1').respond(200, {});
+
+ FeedResource.delete('ye');
+
+ http.flush();
+
+
+ http.expectPOST('base/feeds/1/restore').respond(200, {});
+
+ FeedResource.undoDelete();
+
+ http.flush();
+
+ expect(FeedResource.get('ye').id).toBe(1);
+ }));
+
+
+
+
+ afterEach(() => {
+ http.verifyNoOutstandingExpectation();
+ http.verifyNoOutstandingRequest();
+ });
+
+
});