diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-18 17:47:03 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-04-18 17:47:03 +0200 |
commit | 402c534ee6453e28e5902f3d4f3a21b534309d24 (patch) | |
tree | 483a79a7cc528cb88200db40ff12c526bb542b4c /js/tests | |
parent | 97452a5f5e98e33981eeac1eb89402fc13b13cb2 (diff) |
remove clientside hashing, fix #72
Diffstat (limited to 'js/tests')
6 files changed, 76 insertions, 78 deletions
diff --git a/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee b/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee index 1b9f009d5..f867443c7 100644 --- a/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee +++ b/js/tests/services/businesslayer/feedbusinesslayerSpec.coffee @@ -58,16 +58,16 @@ describe 'FeedBusinessLayer', -> it 'should return the number of unread feeds', => - @FeedModel.add({id: 3, unreadCount:134, urlHash: 'a1'}) + @FeedModel.add({id: 3, unreadCount:134, url: 'a1'}) count = @FeedBusinessLayer.getUnreadCount(3) expect(count).toBe(134) it 'should return all feeds of a folder', => - feed1 = {id: 3, unreadCount:134, urlHash: 'a1', folderId: 3} - feed2 = {id: 4, unreadCount:134, urlHash: 'a2', folderId: 2} - feed3 = {id: 5, unreadCount:134, urlHash: 'a3', folderId: 3} + feed1 = {id: 3, unreadCount:134, url: 'a1', folderId: 3} + feed2 = {id: 4, unreadCount:134, url: 'a2', folderId: 2} + feed3 = {id: 5, unreadCount:134, url: 'a3', folderId: 3} @FeedModel.add(feed1) @FeedModel.add(feed2) @FeedModel.add(feed3) @@ -79,10 +79,10 @@ describe 'FeedBusinessLayer', -> it 'should get the correct unread count for folders', => - @FeedModel.add({id: 3, unreadCount:134, folderId: 3, urlHash: 'a1'}) - @FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a2'}) - @FeedModel.add({id: 1, unreadCount:12, folderId: 5, urlHash: 'a3'}) - @FeedModel.add({id: 2, unreadCount:35, folderId: 3, urlHash: 'a4'}) + @FeedModel.add({id: 3, unreadCount:134, folderId: 3, url: 'a1'}) + @FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a2'}) + @FeedModel.add({id: 1, unreadCount:12, folderId: 5, url: 'a3'}) + @FeedModel.add({id: 2, unreadCount:35, folderId: 3, url: 'a4'}) count = @FeedBusinessLayer.getFolderUnreadCount(3) expect(count).toBe(169) @@ -91,7 +91,7 @@ describe 'FeedBusinessLayer', -> it 'should mark feed as read', => @ActiveFeed.handle({type: @FeedType.Feed, id: 5}) @persistence.setFeedRead = jasmine.createSpy('setFeedRead') - @FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a1'}) + @FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a1'}) @ItemModel.add({id: 6, feedId: 5, guidHash: 'a1'}) @ItemModel.add({id: 3, feedId: 5, guidHash: 'a2'}) @ItemModel.add({id: 2, feedId: 5, guidHash: 'a3'}) @@ -106,7 +106,7 @@ describe 'FeedBusinessLayer', -> it 'should mark feed as read and set 0 if as highest id if its not active',=> @persistence.setFeedRead = jasmine.createSpy('setFeedRead') - @FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a1'}) + @FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a1'}) @ItemModel.add({id: 6, feedId: 5, guidHash: 'a1'}) @ItemModel.add({id: 3, feedId: 5, guidHash: 'a2'}) @ItemModel.add({id: 2, feedId: 5, guidHash: 'a3'}) @@ -121,9 +121,9 @@ describe 'FeedBusinessLayer', -> it 'should mark all as read', => @persistence.setFeedRead = jasmine.createSpy('setFeedRead') - @FeedModel.add({id: 3, unreadCount:134, folderId: 3, urlHash: 'a1'}) - @FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a2'}) - @FeedModel.add({id: 1, unreadCount:12, folderId: 3, urlHash: 'a3'}) + @FeedModel.add({id: 3, unreadCount:134, folderId: 3, url: 'a1'}) + @FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a2'}) + @FeedModel.add({id: 1, unreadCount:12, folderId: 3, url: 'a3'}) @FeedBusinessLayer.markAllRead() @@ -133,16 +133,16 @@ describe 'FeedBusinessLayer', -> it 'should get the correct unread count for subscribtions', => - @FeedModel.add({id: 3, unreadCount:134, urlHash: 'a1'}) - @FeedModel.add({id: 5, unreadCount:2, urlHash: 'a2'}) + @FeedModel.add({id: 3, unreadCount:134, url: 'a1'}) + @FeedModel.add({id: 5, unreadCount:2, url: 'a2'}) count = @FeedBusinessLayer.getAllUnreadCount() expect(count).toBe(136) it 'should return the correct number of feeds', => - @FeedModel.add({id: 3, unreadCount:134, urlHash: 'a1'}) - @FeedModel.add({id: 5, unreadCount:2, urlHash: 'a2'}) + @FeedModel.add({id: 3, unreadCount:134, url: 'a1'}) + @FeedModel.add({id: 5, unreadCount:2, url: 'a2'}) count = @FeedBusinessLayer.getNumberOfFeeds() expect(count).toBe(2) @@ -161,13 +161,13 @@ describe 'FeedBusinessLayer', -> it 'should be visible if unreadcount bigger than 0', => - @FeedModel.add({id: 2, unreadCount:134, urlHash: 'a1'}) + @FeedModel.add({id: 2, unreadCount:134, url: 'a1'}) expect(@FeedBusinessLayer.isVisible(2)).toBe(true) it 'should not move the feed to a new folder', => @persistence.moveFeed = jasmine.createSpy('Move feed') - @FeedModel.add({id: 2, unreadCount:134, urlHash: 'a1', folderId: 3}) + @FeedModel.add({id: 2, unreadCount:134, url: 'a1', folderId: 3}) @FeedBusinessLayer.move(2, 4) expect(@persistence.moveFeed).toHaveBeenCalledWith(2, 4) @@ -176,7 +176,7 @@ describe 'FeedBusinessLayer', -> it 'should not move the feed to the same folder', => @persistence.moveFeed = jasmine.createSpy('Move feed') - @FeedModel.add({id: 2, unreadCount:134, urlHash: 'a1', folderId: 3}) + @FeedModel.add({id: 2, unreadCount:134, url: 'a1', folderId: 3}) @FeedBusinessLayer.move(2, 3) expect(@persistence.moveFeed).not.toHaveBeenCalled() @@ -198,8 +198,8 @@ describe 'FeedBusinessLayer', -> it 'should return all feeds', => - item1 = {id: 2, unreadCount:134, urlHash: 'a1', folderId: 3} - item2 = {id: 4, unreadCount:134, urlHash: 'a2', folderId: 3} + item1 = {id: 2, unreadCount:134, url: 'a1', folderId: 3} + item2 = {id: 4, unreadCount:134, url: 'a2', folderId: 3} @FeedModel.add(item1) @FeedModel.add(item2) @@ -216,9 +216,9 @@ describe 'FeedBusinessLayer', -> it 'should return all feeds of a folder', => - item1 = {id: 2, unreadCount:134, urlHash: 'a1', folderId: 3} - item2 = {id: 4, unreadCount:134, urlHash: 'a2', folderId: 2} - item3 = {id: 5, unreadCount:134, urlHash: 'a3', folderId: 3} + item1 = {id: 2, unreadCount:134, url: 'a1', folderId: 3} + item2 = {id: 4, unreadCount:134, url: 'a2', folderId: 2} + item3 = {id: 5, unreadCount:134, url: 'a3', folderId: 3} @FeedModel.add(item1) @FeedModel.add(item2) @FeedModel.add(item3) @@ -233,7 +233,7 @@ describe 'FeedBusinessLayer', -> item2 = id: 4, unreadCount:134, - urlHash: 'a2', + url: 'a2', folderId: 3, link: 'test.com' @FeedModel.add(item2) @@ -243,7 +243,7 @@ describe 'FeedBusinessLayer', -> it 'should not create a feed if it already exists', => - item1 = {urlHash: hex_md5('john')} + item1 = {url: 'john'} @FeedModel.add(item1) expect => @@ -269,13 +269,11 @@ describe 'FeedBusinessLayer', -> it 'should set a title and an url hash to the newly crated feed', => url = 'www.google.de' @FeedBusinessLayer.create(url) - hash = hex_md5(url) - feed = @FeedModel.getByUrlHash(hash) + feed = @FeedModel.getByUrl(url) expect(feed.title).toBe('www.google.de') expect(feed.url).toBe(url) - expect(feed.urlHash).toBe(hash) expect(feed.folderId).toBe(0) expect(feed.unreadCount).toBe(0) expect(@imagePath).toHaveBeenCalledWith('core', 'loading.gif') @@ -318,22 +316,22 @@ describe 'FeedBusinessLayer', -> expect(onSuccess).not.toHaveBeenCalled() expect(onFailure).toHaveBeenCalled() - expect(@FeedModel.getByUrlHash(hex_md5('johns')).error).toBe( + expect(@FeedModel.getByUrl('johns').error).toBe( @response.msg) it 'should mark a feed error as read by removing it', => - @FeedModel.add({id: 3, urlHash: 'john'}) + @FeedModel.add({id: 3, url: 'john'}) @FeedBusinessLayer.markErrorRead('john') expect(@FeedModel.size()).toBe(0) - expect(@FeedModel.getByUrlHash('john')).toBe(undefined) + expect(@FeedModel.getByUrl('john')).toBe(undefined) it 'should update all feeds', => @persistence.updateFeed = jasmine.createSpy('update') - @FeedModel.add({id: 3, urlHash: 'john'}) + @FeedModel.add({id: 3, url: 'john'}) @FeedBusinessLayer.updateFeeds() @@ -342,7 +340,7 @@ describe 'FeedBusinessLayer', -> it 'should not update feeds without ids', => @persistence.updateFeed = jasmine.createSpy('update') - @FeedModel.add({urlHash: 'john'}) + @FeedModel.add({url: 'john'}) @FeedBusinessLayer.updateFeeds() diff --git a/js/tests/services/businesslayer/folderbusinesslayerSpec.coffee b/js/tests/services/businesslayer/folderbusinesslayerSpec.coffee index a4cb80162..f0241979f 100644 --- a/js/tests/services/businesslayer/folderbusinesslayerSpec.coffee +++ b/js/tests/services/businesslayer/folderbusinesslayerSpec.coffee @@ -54,10 +54,10 @@ describe 'FolderBusinessLayer', -> it 'should return true when folder has feeds', => - @FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a1'}) + @FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a1'}) expect(@FolderBusinessLayer.hasFeeds(3)).toBeFalsy() - @FeedModel.add({id: 2, unreadCount:35, folderId: 3, urlHash: 'a2'}) + @FeedModel.add({id: 2, unreadCount:35, folderId: 3, url: 'a2'}) expect(@FolderBusinessLayer.hasFeeds(3)).toBeTruthy() @@ -80,9 +80,9 @@ describe 'FolderBusinessLayer', -> it 'should mark folder as read', => @persistence.setFeedRead = jasmine.createSpy('setFeedRead') - @FeedModel.add({id: 3, unreadCount:134, folderId: 3, urlHash: 'a1'}) - @FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a2'}) - @FeedModel.add({id: 1, unreadCount:12, folderId: 3, urlHash: 'a3'}) + @FeedModel.add({id: 3, unreadCount:134, folderId: 3, url: 'a1'}) + @FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a2'}) + @FeedModel.add({id: 1, unreadCount:12, folderId: 3, url: 'a3'}) @FolderBusinessLayer.markFolderRead(3) @@ -92,9 +92,9 @@ describe 'FolderBusinessLayer', -> it 'should get the correct unread count', => - @FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a1'}) - @FeedModel.add({id: 6, unreadCount:3, folderId: 3, urlHash: 'a2'}) - @FeedModel.add({id: 7, unreadCount:4, folderId: 2, urlHash: 'a3'}) + @FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a1'}) + @FeedModel.add({id: 6, unreadCount:3, folderId: 3, url: 'a2'}) + @FeedModel.add({id: 7, unreadCount:4, folderId: 2, url: 'a3'}) expect(@FolderBusinessLayer.getUnreadCount(2)).toBe(6) @@ -112,18 +112,18 @@ describe 'FolderBusinessLayer', -> it 'should be visible if one of its subfeeds is active', => - @FeedModel.add({id: 5, unreadCount:0, folderId: 2, urlHash: 'a1'}) - @FeedModel.add({id: 6, unreadCount:0, folderId: 3, urlHash: 'a2'}) - @FeedModel.add({id: 7, unreadCount:0, folderId: 2, urlHash: 'a3'}) + @FeedModel.add({id: 5, unreadCount:0, folderId: 2, url: 'a1'}) + @FeedModel.add({id: 6, unreadCount:0, folderId: 3, url: 'a2'}) + @FeedModel.add({id: 7, unreadCount:0, folderId: 2, url: 'a3'}) @ActiveFeed.handle({type: @FeedType.Feed, id:6}) expect(@FolderBusinessLayer.isVisible(3)).toBe(true) it 'should be visible if showAll is false and it has unread items', => - @FeedModel.add({id: 5, unreadCount:2, folderId: 2, urlHash: 'a1'}) - @FeedModel.add({id: 6, unreadCount:3, folderId: 3, urlHash: 'a2'}) - @FeedModel.add({id: 7, unreadCount:4, folderId: 2, urlHash: 'a3'}) + @FeedModel.add({id: 5, unreadCount:2, folderId: 2, url: 'a1'}) + @FeedModel.add({id: 6, unreadCount:3, folderId: 3, url: 'a2'}) + @FeedModel.add({id: 7, unreadCount:4, folderId: 2, url: 'a3'}) @ActiveFeed.handle({type: @FeedType.Folder, id:2}) expect(@FolderBusinessLayer.isVisible(3)).toBe(true) @@ -415,7 +415,7 @@ describe 'FolderBusinessLayer', -> @persistence.createFolder = jasmine.createSpy('create folder') @persistence.createFeed = jasmine.createSpy('create feed') - @FeedModel.add({urlHash: hex_md5('http://worrydream.com/feed.xml')}) + @FeedModel.add({url: 'http://worrydream.com/feed.xml'}) xml = '<?xml version="1.0" ?> <opml version="1.1"> diff --git a/js/tests/services/businesslayer/itembusinesslayerSpec.coffee b/js/tests/services/businesslayer/itembusinesslayerSpec.coffee index 5f4744ffa..0b8358f2a 100644 --- a/js/tests/services/businesslayer/itembusinesslayerSpec.coffee +++ b/js/tests/services/businesslayer/itembusinesslayerSpec.coffee @@ -33,7 +33,7 @@ describe 'ItemBusinessLayer', -> beforeEach inject (@ItemModel, @ItemBusinessLayer, @StatusFlag, @ActiveFeed @FeedType, @FeedModel, @StarredBusinessLayer) => - @item1 = {id: 5, title: 'hi', unreadCount:134, urlHash: 'a3', folderId: 3} + @item1 = {id: 5, title: 'hi', unreadCount:134, url: 'a3', folderId: 3} @FeedModel.add(@item1) @ActiveFeed.handle({type: @FeedType.Feed, id: 3}) diff --git a/js/tests/services/businesslayer/subsriptionsbusinesslayerSpec.coffee b/js/tests/services/businesslayer/subsriptionsbusinesslayerSpec.coffee index 48ae9e03c..090433fbd 100644 --- a/js/tests/services/businesslayer/subsriptionsbusinesslayerSpec.coffee +++ b/js/tests/services/businesslayer/subsriptionsbusinesslayerSpec.coffee @@ -40,7 +40,7 @@ describe 'SubscriptionsBusinessLayer', -> it 'should be visible shows all items is set to true and there are feeds', => - @FeedModel.add({id: 3, unreadCount: 5, urlHash: 'hi'}) + @FeedModel.add({id: 3, unreadCount: 5, url: 'hi'}) expect(@SubscriptionsBusinessLayer.isVisible()).toBe(true) @@ -66,7 +66,7 @@ describe 'SubscriptionsBusinessLayer', -> it 'should mark all feeds as read', => - item = {id: 3, unreadCount: 132, urlHash: 'hi'} + item = {id: 3, unreadCount: 132, url: 'hi'} @FeedModel.add(item) @SubscriptionsBusinessLayer.markAllRead() @@ -76,8 +76,8 @@ describe 'SubscriptionsBusinessLayer', -> it 'should get the correct unread count', => - @FeedModel.add({id: 3, unreadCount: 132, urlHash: 'hoho'}) - @FeedModel.add({id: 4, unreadCount: 12, urlHash: 'hohod'}) + @FeedModel.add({id: 3, unreadCount: 132, url: 'hoho'}) + @FeedModel.add({id: 4, unreadCount: 12, url: 'hohod'}) expect(@SubscriptionsBusinessLayer.getUnreadCount()).toBe(144) diff --git a/js/tests/services/models/feedmodelSpec.coffee b/js/tests/services/models/feedmodelSpec.coffee index 6b6eb85f6..082e1aa32 100644 --- a/js/tests/services/models/feedmodelSpec.coffee +++ b/js/tests/services/models/feedmodelSpec.coffee @@ -45,7 +45,7 @@ describe 'FeedModel', -> item = id: 3 faviconLink: null - urlHash: 'hi' + url: 'hi' @FeedModel.add(item) @@ -53,82 +53,82 @@ describe 'FeedModel', -> it 'should add feeds without id', => - item = {faviconLink: null, urlHash: 'hi'} + item = {faviconLink: null, url: 'hi'} @FeedModel.add(item) - item2 = {faviconLink: null, urlHash: 'his'} + item2 = {faviconLink: null, url: 'his'} @FeedModel.add(item2) - expect(@FeedModel.getByUrlHash('hi')).toBe(item) + expect(@FeedModel.getByUrl('hi')).toBe(item) expect(@FeedModel.size()).toBe(2) - it 'should clear the url hash cache', => - item = {faviconLink: null, urlHash: 'hi'} + it 'should clear the url cache', => + item = {faviconLink: null, url: 'hi'} @FeedModel.add(item) @FeedModel.clear() - expect(@FeedModel.getByUrlHash('hi')).toBe(undefined) + expect(@FeedModel.getByUrl('hi')).toBe(undefined) expect(@FeedModel.size()).toBe(0) it 'should delete items from the fodername cache', => - item = {id:3, faviconLink: null, urlHash: 'hi'} + item = {id:3, faviconLink: null, url: 'hi'} @FeedModel.add(item) expect(@FeedModel.size()).toBe(1) @FeedModel.removeById(3) - expect(@FeedModel.getByUrlHash('hi')).toBe(undefined) + expect(@FeedModel.getByUrl('hi')).toBe(undefined) expect(@FeedModel.size()).toBe(0) it 'should update the id if an update comes in with an id', => - item = {faviconLink: null, urlHash: 'hi', test: 'heheh'} + item = {faviconLink: null, url: 'hi', test: 'heheh'} @FeedModel.add(item) - item2 = {id: 3, faviconLink: null, urlHash: 'hi', test: 'hoho'} + item2 = {id: 3, faviconLink: null, url: 'hi', test: 'hoho'} @FeedModel.add(item2) - expect(@FeedModel.getByUrlHash('hi').id).toBe(3) - expect(@FeedModel.getByUrlHash('hi').test).toBe('hoho') + expect(@FeedModel.getByUrl('hi').id).toBe(3) + expect(@FeedModel.getByUrl('hi').test).toBe('hoho') expect(@FeedModel.getById(3).id).toBe(3) expect(@FeedModel.getById(3).test).toBe('hoho') expect(@FeedModel.size()).toBe(1) it 'should update normally', => - item = {id: 3, faviconLink: null, urlHash: 'hi', test: 'heheh'} + item = {id: 3, faviconLink: null, url: 'hi', test: 'heheh'} @FeedModel.add(item) - item2 = {id: 3, faviconLink: null, urlHash: 'his', test: 'hoho'} + item2 = {id: 3, faviconLink: null, url: 'his', test: 'hoho'} @FeedModel.add(item2) - expect(@FeedModel.getByUrlHash('hi')).toBe(undefined) - expect(@FeedModel.getByUrlHash('his').id).toBe(3) - expect(@FeedModel.getByUrlHash('his').test).toBe('hoho') + expect(@FeedModel.getByUrl('hi')).toBe(undefined) + expect(@FeedModel.getByUrl('his').id).toBe(3) + expect(@FeedModel.getByUrl('his').test).toBe('hoho') expect(@FeedModel.getById(3).test).toBe('hoho') expect(@FeedModel.size()).toBe(1) it 'should clear invalidate the query cache on adding folder with name', => - item = {faviconLink: null, urlHash: 'hi', test: 'heheh', folderId: 0} + item = {faviconLink: null, url: 'hi', test: 'heheh', folderId: 0} expect(@FeedModel.getAllOfFolder(0).length).toBe(0) @FeedModel.add(item, false) expect(@FeedModel.getAllOfFolder(0).length).toBe(0) - item2 = {faviconLink: null, urlHash: 'his', test: 'heheh', folderId: 0} + item2 = {faviconLink: null, url: 'his', test: 'heheh', folderId: 0} @FeedModel.add(item2) expect(@FeedModel.getAllOfFolder(0).length).toBe(2) - it 'should only update feeds that contain only an id but no url hash', => + it 'should only update feeds that contain only an id but no url', => item = {id: 3, unreadCount: 232} @FeedModel.add(item) expect(@FeedModel.size()).toBe(0) - item2 = {id: 3, unreadCount: 2, faviconLink: null, urlHash: 'his'} + item2 = {id: 3, unreadCount: 2, faviconLink: null, url: 'his'} @FeedModel.add(item2) @FeedModel.add(item) diff --git a/js/tests/services/models/itemmodelSpec.coffee b/js/tests/services/models/itemmodelSpec.coffee index 4e93609ea..2171f12ea 100644 --- a/js/tests/services/models/itemmodelSpec.coffee +++ b/js/tests/services/models/itemmodelSpec.coffee @@ -57,7 +57,7 @@ describe 'ItemModel', -> expect(@ItemModel.size()).toBe(2) - it 'should also remove the feed from the urlHash cache when its removed', => + it 'should also remove the feed from the url cache when its removed', => item = {id: 4, guidHash: 'abc', feedId: 3} @ItemModel.add(item) |