summaryrefslogtreecommitdiffstats
path: root/js/tests
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-19 15:51:26 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-19 15:51:26 +0200
commit11f0246acd0daab1067eb32099fa26f05a26ea21 (patch)
tree67012a66a89be2f43910dee41a6e023d7645b29b /js/tests
parent928ccf49fb5c6deb405358ad38221b0cd205fb6b (diff)
subscribe to more channels and fetch more feeds on init
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/service/ItemSpec.js43
-rw-r--r--js/tests/unit/service/PublisherSpec.js19
2 files changed, 60 insertions, 2 deletions
diff --git a/js/tests/unit/service/ItemSpec.js b/js/tests/unit/service/ItemSpec.js
new file mode 100644
index 000000000..85ee5789e
--- /dev/null
+++ b/js/tests/unit/service/ItemSpec.js
@@ -0,0 +1,43 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+describe('Item', function () {
+ 'use strict';
+
+ beforeEach(module('News'));
+
+
+ it('should receive the newestItemId', inject(function (Item) {
+ Item.receive(3, 'newestItemId');
+
+ expect(Item.getNewestItemId()).toBe(3);
+ }));
+
+
+ it('should receive the newestItemId', inject(function (Item) {
+ Item.receive(2, 'starred');
+
+ expect(Item.getStarredCount()).toBe(2);
+ }));
+
+
+ it('should receive items', inject(function (Item) {
+ Item.receive([
+ {
+ id: 3
+ },
+ {
+ id: 4
+ }
+ ], 'items');
+
+ expect(Item.size()).toBe(2);
+ }));
+
+}); \ No newline at end of file
diff --git a/js/tests/unit/service/PublisherSpec.js b/js/tests/unit/service/PublisherSpec.js
index 2b9206c93..8d7b65e58 100644
--- a/js/tests/unit/service/PublisherSpec.js
+++ b/js/tests/unit/service/PublisherSpec.js
@@ -17,13 +17,28 @@ describe('Publisher', function () {
var obj = {
receive: jasmine.createSpy('receive')
};
- Publisher.subscribe(obj).toChannel('test');
+ Publisher.subscribe(obj).toChannels('test');
Publisher.publishAll({
test: 'tom'
});
- expect(obj.receive).toHaveBeenCalledWith('tom');
+ expect(obj.receive).toHaveBeenCalledWith('tom', 'test');
+ }));
+
+
+ it('should should publish on all possible channels', inject(function (Publisher) {
+
+ var obj = {
+ receive: jasmine.createSpy('receive')
+ };
+ Publisher.subscribe(obj).toChannels('test', 'tiny');
+
+ Publisher.publishAll({
+ tiny: 'tom'
+ });
+
+ expect(obj.receive).toHaveBeenCalledWith('tom', 'tiny');
}));