This commit is contained in:
Bernhard Posselt 2016-04-12 22:15:58 +02:00
Родитель 3df007e7c0
Коммит d0401257f6
6 изменённых файлов: 396 добавлений и 314 удалений

Просмотреть файл

@ -23,7 +23,6 @@ use \OCP\AppFramework\Db\Entity;
* @method void setGuid(string $value)
* @method string getGuidHash()
* @method void setGuidHash(string $value)
* @method string getGuid()
* @method string getUrl()
* @method string getTitle()
* @method string getAuthor()
@ -131,7 +130,8 @@ class Item extends Entity implements IAPI, \JsonSerializable {
'starred' => $this->isStarred(),
'lastModified' => $this->getLastModified(),
'rtl' => $this->getRtl(),
'intro' => $this->getIntro()
'intro' => $this->getIntro(),
'fingerprint' => $this->getFingerprint()
];
}
@ -151,7 +151,8 @@ class Item extends Entity implements IAPI, \JsonSerializable {
'unread' => $this->isUnread(),
'starred' => $this->isStarred(),
'lastModified' => $this->getLastModified(),
'rtl' => $this->getRtl()
'rtl' => $this->getRtl(),
'fingerprint' => $this->getFingerprint()
];
}

Просмотреть файл

@ -23,6 +23,7 @@ app.factory('ItemResource', function (Resource, $http, BASE_URL,
this.starredCount = 0;
this.lowestId = 0;
this.highestId = 0;
this.fingerprints = {};
Resource.prototype.clear.call(this);
};
@ -39,6 +40,7 @@ app.factory('ItemResource', function (Resource, $http, BASE_URL,
default:
var self = this;
var importValues = [];
value.forEach(function (item) {
// initialize lowest and highest id
if (self.lowestId === 0) {
@ -54,9 +56,15 @@ app.factory('ItemResource', function (Resource, $http, BASE_URL,
if (item.id < self.lowestId) {
self.lowestId = item.id;
}
// filter out duplicates
if (self.fingerprints[item.fingerprint] === undefined) {
self.fingerprints[item.fingerprint] = true;
importValues.push(item);
}
});
Resource.prototype.receive.call(this, value, channel);
Resource.prototype.receive.call(this, importValues, channel);
}
};

Просмотреть файл

@ -62,7 +62,7 @@ app.factory('Resource', function () {
if (deleteAtIndex !== undefined) {
this.values.splice(deleteAtIndex, 1);
}
if (this.hashMap[id] !== undefined) {
delete this.hashMap[id];
}

Просмотреть файл

@ -25,27 +25,27 @@ describe('ContentController', function () {
}));
it('should publish data to models', inject(function ($controller, Publisher,
FeedResource, ItemResource) {
it('should publish data to models',
inject(function ($controller, Publisher, FeedResource, ItemResource) {
Publisher.subscribe(ItemResource).toChannels(['items']);
Publisher.subscribe(FeedResource).toChannels(['feeds']);
Publisher.subscribe(ItemResource).toChannels(['items']);
Publisher.subscribe(FeedResource).toChannels(['feeds']);
var controller = $controller('ContentController', {
data: {
'items': [
{id: 3},
{id: 4}
]
}
});
var controller = $controller('ContentController', {
data: {
'items': [
{id: 3, fingerprint: 'a'},
{id: 4, fingerprint: 'b'}
]
}
});
expect(controller.getItems().length).toBe(2);
}));
expect(controller.getItems().length).toBe(2);
}));
it('should clear data on url change', inject(function ($controller,
ItemResource) {
ItemResource) {
ItemResource.clear = jasmine.createSpy('clear');
@ -57,58 +57,59 @@ describe('ContentController', function () {
}));
it('should return order by', inject(function ($controller,
SettingsResource, FEED_TYPE) {
var route = {
current: {
$$route: {
type: FEED_TYPE.FOLDER
it('should return order by',
inject(function ($controller, SettingsResource, FEED_TYPE) {
var route = {
current: {
$$route: {
type: FEED_TYPE.FOLDER
}
}
}
};
};
var ctrl = $controller('ContentController', {
data: {},
$route: route
});
var ctrl = $controller('ContentController', {
data: {},
$route: route
});
expect(ctrl.orderBy()).toBe('-id');
expect(ctrl.orderBy()).toBe('-id');
SettingsResource.set('oldestFirst', true);
SettingsResource.set('oldestFirst', true);
expect(ctrl.orderBy()).toBe('id');
}));
expect(ctrl.orderBy()).toBe('id');
}));
it('should return order if custom ordering', inject(function ($controller,
SettingsResource, FeedResource, FEED_TYPE) {
var route = {
current: {
$$route: {
type: FEED_TYPE.FEED
it('should return order if custom ordering',
inject(function ($controller, SettingsResource, FeedResource,
FEED_TYPE) {
var route = {
current: {
$$route: {
type: FEED_TYPE.FEED
}
}
}
};
FeedResource.receive([
{id: 1, folderId: 3, url: 'ye', unreadCount: 45, ordering: 1},
]);
var ctrl = $controller('ContentController', {
data: {},
$route: route,
$routeParams: {
id: 1
}
});
};
FeedResource.receive([
{id: 1, folderId: 3, url: 'ye', unreadCount: 45, ordering: 1},
]);
var ctrl = $controller('ContentController', {
data: {},
$route: route,
$routeParams: {
id: 1
}
});
expect(ctrl.orderBy()).toBe('id');
expect(ctrl.orderBy()).toBe('id');
SettingsResource.set('oldestFirst', true);
SettingsResource.set('oldestFirst', true);
expect(ctrl.orderBy()).toBe('id');
}));
expect(ctrl.orderBy()).toBe('id');
}));
it('should mark read', inject(function ($controller, ItemResource,
FeedResource, Publisher) {
FeedResource, Publisher) {
Publisher.subscribe(ItemResource).toChannels(['items']);
ItemResource.markItemRead = jasmine.createSpy('markRead');
@ -118,21 +119,25 @@ describe('ContentController', function () {
ItemResource: ItemResource,
FeedResource: FeedResource,
data: {
'items': [{
id: 3,
feedId: 4,
unread: true
},
{
id: 5,
feedId: 4,
keepUnread: true
},
{
id: 9,
feedId: 5,
unread: false
}]
'items': [
{
id: 3,
feedId: 4,
fingerprint: 'a',
unread: true
},
{
id: 5,
feedId: 4,
fingerprint: 'b',
keepUnread: true
},
{
id: 9,
feedId: 5,
fingerprint: 'c',
unread: false
}]
},
});
@ -147,59 +152,59 @@ describe('ContentController', function () {
}));
it('should toggle keep unread when unread', inject(function ($controller,
ItemResource, FeedResource, Publisher) {
it('should toggle keep unread when unread',
inject(function ($controller, ItemResource, FeedResource, Publisher) {
Publisher.subscribe(ItemResource).toChannels(['items']);
Publisher.subscribe(ItemResource).toChannels(['items']);
var ctrl = $controller('ContentController', {
ItemResource: ItemResource,
FeedResource: FeedResource,
data: {
'items': [{
id: 3,
feedId: 4,
unread: true
}]
},
});
var ctrl = $controller('ContentController', {
ItemResource: ItemResource,
FeedResource: FeedResource,
data: {
'items': [{
id: 3,
feedId: 4,
unread: true
}]
},
});
ctrl.toggleKeepUnread(3);
ctrl.toggleKeepUnread(3);
expect(ItemResource.get(3).keepUnread).toBe(true);
}));
expect(ItemResource.get(3).keepUnread).toBe(true);
}));
it('should toggle keep unread when read', inject(function ($controller,
ItemResource, FeedResource, Publisher) {
it('should toggle keep unread when read',
inject(function ($controller, ItemResource, FeedResource, Publisher) {
Publisher.subscribe(ItemResource).toChannels(['items']);
ItemResource.markItemRead = jasmine.createSpy('markRead');
FeedResource.markItemOfFeedUnread = jasmine.createSpy('markRead');
Publisher.subscribe(ItemResource).toChannels(['items']);
ItemResource.markItemRead = jasmine.createSpy('markRead');
FeedResource.markItemOfFeedUnread = jasmine.createSpy('markRead');
var ctrl = $controller('ContentController', {
ItemResource: ItemResource,
FeedResource: FeedResource,
data: {
'items': [{
id: 3,
feedId: 4,
unread: false,
keepUnread: true
}]
},
});
var ctrl = $controller('ContentController', {
ItemResource: ItemResource,
FeedResource: FeedResource,
data: {
'items': [{
id: 3,
feedId: 4,
unread: false,
keepUnread: true
}]
},
});
ctrl.toggleKeepUnread(3);
ctrl.toggleKeepUnread(3);
expect(ItemResource.get(3).keepUnread).toBe(false);
expect(ItemResource.markItemRead).toHaveBeenCalledWith(3, false);
expect(FeedResource.markItemOfFeedUnread).toHaveBeenCalledWith(4);
}));
expect(ItemResource.get(3).keepUnread).toBe(false);
expect(ItemResource.markItemRead).toHaveBeenCalledWith(3, false);
expect(FeedResource.markItemOfFeedUnread).toHaveBeenCalledWith(4);
}));
it('should get a feed', inject(function ($controller, FeedResource,
Publisher) {
Publisher) {
Publisher.subscribe(FeedResource).toChannels(['feeds']);
@ -232,9 +237,8 @@ describe('ContentController', function () {
}));
it('should publish compactview', inject(function ($controller,
SettingsResource) {
SettingsResource) {
SettingsResource.set('compact', true);
@ -247,21 +251,21 @@ describe('ContentController', function () {
}));
it('should publish compact expand setting', inject(function ($controller,
SettingsResource) {
it('should publish compact expand setting',
inject(function ($controller, SettingsResource) {
SettingsResource.set('compactExpand', true);
SettingsResource.set('compactExpand', true);
var ctrl = $controller('ContentController', {
SettingsResource: SettingsResource,
data: {},
});
var ctrl = $controller('ContentController', {
SettingsResource: SettingsResource,
data: {},
});
expect(ctrl.isCompactExpand()).toBe(true);
}));
expect(ctrl.isCompactExpand()).toBe(true);
}));
it('should publish markread', inject(function ($controller,
SettingsResource) {
SettingsResource) {
SettingsResource.set('preventReadOnScroll', true);
@ -283,214 +287,237 @@ describe('ContentController', function () {
}));
it('should mark multiple items read', inject(function ($controller,
ItemResource, FeedResource, Publisher) {
it('should mark multiple items read',
inject(function ($controller, ItemResource, FeedResource, Publisher) {
Publisher.subscribe(ItemResource).toChannels(['items']);
ItemResource.markItemsRead = jasmine.createSpy('markRead');
FeedResource.markItemsOfFeedsRead = jasmine.createSpy('markRead');
Publisher.subscribe(ItemResource).toChannels(['items']);
ItemResource.markItemsRead = jasmine.createSpy('markRead');
FeedResource.markItemsOfFeedsRead = jasmine.createSpy('markRead');
var ctrl = $controller('ContentController', {
ItemResource: ItemResource,
FeedResource: FeedResource,
data: {
'items': [{
id: 3,
feedId: 6
var ctrl = $controller('ContentController', {
ItemResource: ItemResource,
FeedResource: FeedResource,
data: {
'items': [
{
id: 3,
fingerprint: 'a',
feedId: 6
},
{
id: 2,
fingerprint: 'b',
feedId: 4,
keepUnread: true
},
{
id: 1,
fingerprint: 'c',
feedId: 4
},]
},
{
id: 2,
feedId: 4,
keepUnread: true
},
{
id: 1,
feedId: 4
},]
},
});
});
ctrl.scrollRead([3, 2, 1]);
ctrl.scrollRead([3, 2, 1]);
expect(ItemResource.markItemsRead).toHaveBeenCalledWith([3, 1]);
expect(FeedResource.markItemsOfFeedsRead).toHaveBeenCalledWith([6, 4]);
}));
expect(ItemResource.markItemsRead).toHaveBeenCalledWith([3, 1]);
expect(FeedResource.markItemsOfFeedsRead)
.toHaveBeenCalledWith([6, 4]);
}));
it('should not autopage if less than 0 elements', inject(function (
$controller, ItemResource, Publisher, SettingsResource, Loading) {
SettingsResource.set('oldestFirst', true);
SettingsResource.set('showAll', false);
it('should not autopage if less than 0 elements',
inject(function ($controller, ItemResource, Publisher,
SettingsResource, Loading) {
SettingsResource.set('oldestFirst', true);
SettingsResource.set('showAll', false);
var $location = {
search: jasmine.createSpy('search').and.returnValue({
search: 'some+string'
})
};
var $location = {
search: jasmine.createSpy('search').and.returnValue({
search: 'some+string'
})
};
var $route = {
current: {
$$route: {
type: 3
var $route = {
current: {
$$route: {
type: 3
}
}
}
};
};
var $routeParams = {
id: 2
};
Publisher.subscribe(ItemResource).toChannels(['items']);
ItemResource.autoPage = jasmine.createSpy('autoPage')
.and.callFake(function () {
return {
success: function (callback) {
callback({
'items': []
});
var $routeParams = {
id: 2
};
Publisher.subscribe(ItemResource).toChannels(['items']);
ItemResource.autoPage = jasmine.createSpy('autoPage')
.and.callFake(function () {
return {
error: function () {
success: function (callback) {
callback({
'items': []
});
return {
finally: function (callback) {
callback();
error: function () {
return {
finally: function (callback) {
callback();
}
};
}
};
}
};
});
var ctrl = $controller('ContentController', {
$routeParams: $routeParams,
$route: $route,
Publisher: Publisher,
ItemResource: ItemResource,
SettingsResource: SettingsResource,
data: {'items': [{id: 3}, {id: 4}]},
$location: $location
});
expect(ctrl.autoPagingEnabled()).toBe(true);
ctrl.autoPage();
expect(ctrl.autoPagingEnabled()).toBe(false);
expect(Loading.isLoading('autopaging')).toBe(false);
expect(ItemResource.autoPage)
.toHaveBeenCalledWith(3, 2, true, false, 'some+string');
}));
it('should autopage if more than 0 elements',
inject(function ($controller, ItemResource, Publisher) {
var $route = {
current: {
$$route: {
type: 3
}
}
};
});
var ctrl = $controller('ContentController', {
$routeParams: $routeParams,
$route: $route,
Publisher: Publisher,
ItemResource: ItemResource,
SettingsResource: SettingsResource,
data: {'items': [{id: 3}, {id: 4}]},
$location: $location
});
expect(ctrl.autoPagingEnabled()).toBe(true);
ctrl.autoPage();
expect(ctrl.autoPagingEnabled()).toBe(false);
expect(Loading.isLoading('autopaging')).toBe(false);
expect(ItemResource.autoPage).toHaveBeenCalledWith(3, 2, true, false,
'some+string');
}));
it('should autopage if more than 0 elements', inject(function (
$controller, ItemResource, Publisher) {
var $route = {
current: {
$$route: {
type: 3
}
}
};
var $routeParams = {
id: 2
};
Publisher.subscribe(ItemResource).toChannels(['items']);
ItemResource.autoPage = jasmine.createSpy('autoPage')
.and.callFake(function () {
return {
success: function (callback) {
callback({
'items': [{items: [{id: 3}]}]
});
var $routeParams = {
id: 2
};
Publisher.subscribe(ItemResource).toChannels(['items']);
ItemResource.autoPage = jasmine.createSpy('autoPage')
.and.callFake(function () {
return {
error: function () {
success: function (callback) {
callback({
'items': [{items: [{id: 3, fingerprint: 'a'}]}]
});
return {
finally: function () {}
error: function () {
return {
finally: function () {
}
};
}
};
}
};
});
var ctrl = $controller('ContentController', {
$routeParams: $routeParams,
$route: $route,
Publisher: Publisher,
ItemResource: ItemResource,
data: {
'items': [{
id: 3, fingerprint: 'a'
}, {
id: 4, fingerprint: 'b'
}]
},
});
expect(ctrl.autoPagingEnabled()).toBe(true);
ctrl.autoPage();
expect(ctrl.autoPagingEnabled()).toBe(true);
expect(ItemResource.size()).toBe(3);
}));
it('should autopage if error',
inject(function ($controller, ItemResource, Publisher) {
var $route = {
current: {
$$route: {
type: 3
}
}
};
});
var ctrl = $controller('ContentController', {
$routeParams: $routeParams,
$route: $route,
Publisher: Publisher,
ItemResource: ItemResource,
data: {'items': [{id: 3}, {id: 4}]},
});
expect(ctrl.autoPagingEnabled()).toBe(true);
ctrl.autoPage();
expect(ctrl.autoPagingEnabled()).toBe(true);
expect(ItemResource.size()).toBe(3);
}));
it('should autopage if error', inject(function (
$controller, ItemResource, Publisher) {
var $route = {
current: {
$$route: {
type: 3
}
}
};
var $routeParams = {
id: 2
};
Publisher.subscribe(ItemResource).toChannels(['items']);
ItemResource.autoPage = jasmine.createSpy('autoPage')
.and.callFake(function () {
return {
success: function (callback) {
callback({
'items': []
});
var $routeParams = {
id: 2
};
Publisher.subscribe(ItemResource).toChannels(['items']);
ItemResource.autoPage = jasmine.createSpy('autoPage')
.and.callFake(function () {
return {
error: function (callback) {
callback();
success: function (callback) {
callback({
'items': []
});
return {
finally: function () {}
error: function (callback) {
callback();
return {
finally: function () {
}
};
}
};
}
};
}
};
});
});
var ctrl = $controller('ContentController', {
$routeParams: $routeParams,
$route: $route,
Publisher: Publisher,
ItemResource: ItemResource,
data: {'items': [{id: 3}, {id: 4}]},
});
var ctrl = $controller('ContentController', {
$routeParams: $routeParams,
$route: $route,
Publisher: Publisher,
ItemResource: ItemResource,
data: {
'items': [
{
id: 3,
fingerprint: 'a'
}, {
id: 4,
fingerprint: 'b'
}]
},
});
expect(ctrl.autoPagingEnabled()).toBe(true);
expect(ctrl.autoPagingEnabled()).toBe(true);
ctrl.autoPage();
ctrl.autoPage();
expect(ctrl.autoPagingEnabled()).toBe(true);
}));
expect(ctrl.autoPagingEnabled()).toBe(true);
}));
it('should return relative date', inject(function ($controller,
SettingsResource) {
SettingsResource) {
SettingsResource.receive({language: 'en'});
var ctrl = $controller('ContentController', {
@ -524,7 +551,7 @@ describe('ContentController', function () {
}));
it('should tell if a feed is shown', inject(function ($controller,
FEED_TYPE) {
FEED_TYPE) {
var $route = {
current: {
@ -553,7 +580,7 @@ describe('ContentController', function () {
}));
it('should publish showall', inject(function ($controller,
SettingsResource) {
SettingsResource) {
SettingsResource.set('showAll', true);

Просмотреть файл

@ -33,6 +33,24 @@ describe('ItemResource', function () {
expect(ItemResource.getNewestItemId()).toBe(3);
}));
it('should filter out item duplicates', inject(function (ItemResource) {
ItemResource.receive([{
id: 3,
fingerprint: 'a'
}, {
id: 4,
fingerprint: 'a'
}, {
id: 2,
fingerprint: 'b'
}], 'items');
expect(ItemResource.get(3).fingerprint).toBe('a');
expect(ItemResource.get(2).fingerprint).toBe('b');
expect(ItemResource.get(4)).toBe(undefined);
expect(ItemResource.highestId).toBe(4);
expect(ItemResource.lowestId).toBe(2);
}));
it('should receive the newestItemId', inject(function (ItemResource) {
ItemResource.receive(2, 'starred');
@ -41,19 +59,21 @@ describe('ItemResource', function () {
}));
it ('should mark item as read', inject(function (ItemResource) {
it('should mark item as read', inject(function (ItemResource) {
http.expectPOST('base/items/3/read', {isRead: true}).respond(200, {});
ItemResource.receive([
{
id: 3,
feedId: 4,
unread: true
unread: true,
fingerprint: 'a'
},
{
id: 4,
feedId: 3,
unread: true
unread: true,
fingerprint: 'b'
}
], 'items');
@ -65,7 +85,7 @@ describe('ItemResource', function () {
}));
it ('should mark multiple item as read', inject(function (ItemResource) {
it('should mark multiple item as read', inject(function (ItemResource) {
http.expectPOST('base/items/read/multiple', {
itemIds: [3, 4]
}).respond(200, {});
@ -74,12 +94,14 @@ describe('ItemResource', function () {
{
id: 3,
feedId: 4,
unread: true
unread: true,
fingerprint: 'a'
},
{
id: 4,
feedId: 3,
unread: true
unread: true,
fingerprint: 'b'
}
], 'items');
@ -92,8 +114,7 @@ describe('ItemResource', function () {
}));
it ('should star item', inject(function (ItemResource) {
it('should star item', inject(function (ItemResource) {
http.expectPOST('base/items/4/a/star', {isStarred: true})
.respond(200, {});
@ -101,12 +122,14 @@ describe('ItemResource', function () {
{
id: 3,
feedId: 4,
fingerprint: 'a',
starred: false,
guidHash: 'a'
},
{
id: 4,
feedId: 3,
fingerprint: 'b',
starred: false
}
], 'items');
@ -120,7 +143,7 @@ describe('ItemResource', function () {
}));
it ('should mark feed as read', inject(function (ItemResource) {
it('should mark feed as read', inject(function (ItemResource) {
http.expectPOST('base/feeds/4/read', {
highestItemId: 5
}).respond(200, {});
@ -129,16 +152,19 @@ describe('ItemResource', function () {
{
id: 3,
feedId: 4,
fingerprint: 'a',
unread: true
},
{
id: 4,
feedId: 3,
fingerprint: 'b',
unread: true
},
{
id: 5,
feedId: 4,
fingerprint: 'c',
unread: true
}
], 'items');
@ -153,7 +179,7 @@ describe('ItemResource', function () {
}));
it ('should mark all as read', inject(function (ItemResource) {
it('should mark all as read', inject(function (ItemResource) {
http.expectPOST('base/items/read', {
highestItemId: 5
}).respond(200, {});
@ -162,16 +188,19 @@ describe('ItemResource', function () {
{
id: 3,
feedId: 4,
fingerprint: 'a',
unread: true
},
{
id: 5,
feedId: 3,
fingerprint: 'b',
unread: true
},
{
id: 4,
feedId: 4,
fingerprint: 'c',
unread: true
}
], 'items');
@ -187,14 +216,16 @@ describe('ItemResource', function () {
}));
it ('toggle star', inject(function (ItemResource) {
it('toggle star', inject(function (ItemResource) {
ItemResource.receive([
{
id: 3,
fingerprint: 'a',
starred: true
},
{
id: 5,
fingerprint: 'b',
starred: false
}
], 'items');
@ -209,7 +240,7 @@ describe('ItemResource', function () {
}));
it ('should auto page newest first', inject(function (ItemResource) {
it('should auto page newest first', inject(function (ItemResource) {
http.expectGET(
'base/items?id=4&limit=5&offset=3&oldestFirst=false&type=3')
.respond(200, {});
@ -218,16 +249,19 @@ describe('ItemResource', function () {
{
id: 3,
feedId: 4,
fingerprint: 'a',
unread: true
},
{
id: 5,
feedId: 3,
fingerprint: 'b',
unread: true
},
{
id: 4,
feedId: 4,
fingerprint: 'c',
unread: true
}
], 'items');
@ -238,7 +272,7 @@ describe('ItemResource', function () {
}));
it ('should auto page oldest first', inject(function (ItemResource) {
it('should auto page oldest first', inject(function (ItemResource) {
http.expectGET(
'base/items?id=4&limit=5&offset=5&oldestFirst=true&type=3')
.respond(200, {});
@ -247,16 +281,19 @@ describe('ItemResource', function () {
{
id: 3,
feedId: 4,
fingerprint: 'a',
unread: true
},
{
id: 5,
feedId: 3,
fingerprint: 'b',
unread: true
},
{
id: 4,
feedId: 4,
fingerprint: 'c',
unread: true
}
], 'items');
@ -267,26 +304,29 @@ describe('ItemResource', function () {
}));
it ('should auto page all', inject(function (ItemResource) {
it('should auto page all', inject(function (ItemResource) {
http.expectGET(
'base/items?id=4&limit=5&offset=5&oldestFirst=true' +
'&search=some+string&showAll=true&type=3')
'base/items?id=4&limit=5&offset=5&oldestFirst=true' +
'&search=some+string&showAll=true&type=3')
.respond(200, {});
ItemResource.receive([
{
id: 3,
feedId: 4,
fingerprint: 'a',
unread: true
},
{
id: 5,
feedId: 3,
fingerprint: 'b',
unread: true
},
{
id: 4,
feedId: 4,
fingerprint: 'c',
unread: true
}
], 'items');
@ -297,21 +337,24 @@ describe('ItemResource', function () {
}));
it ('should clear all state', inject(function (ItemResource) {
it('should clear all state', inject(function (ItemResource) {
ItemResource.receive([
{
id: 3,
feedId: 4,
fingerprint: 'a',
unread: true
},
{
id: 5,
feedId: 3,
fingerprint: 'b',
unread: true
},
{
id: 4,
feedId: 4,
fingerprint: 'c',
unread: true
}
], 'items');
@ -327,8 +370,7 @@ describe('ItemResource', function () {
}));
it ('should import articles', inject(function (ItemResource) {
it('should import articles', inject(function (ItemResource) {
var json = 'test';
http.expectPOST('base/feeds/import/articles', {

Просмотреть файл

@ -70,6 +70,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
$item->setUnread();
$item->setStarred();
$item->setLastModified(321);
$item->setFingerprint('fingerprint');
$this->assertEquals([
'id' => 3,
@ -86,7 +87,8 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
'unread' => true,
'starred' => true,
'lastModified' => 321,
'rtl' => true
'rtl' => true,
'fingerprint' => 'fingerprint'
], $item->toAPI());
}
@ -107,6 +109,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
$item->setStatus(0);
$item->setRtl(true);
$item->setUnread();
$item->setFingerprint('fingerprint');
$item->setStarred();
$item->setLastModified(321);
@ -126,7 +129,8 @@ class ItemTest extends \PHPUnit_Framework_TestCase {
'starred' => true,
'lastModified' => 321,
'rtl' => true,
'intro' => 'this is a test'
'intro' => 'this is a test',
'fingerprint' => 'fingerprint'
], $item->jsonSerialize());
}