diff options
Diffstat (limited to 'js/tests/unit/service')
-rw-r--r-- | js/tests/unit/service/ItemSpec.js | 43 | ||||
-rw-r--r-- | js/tests/unit/service/PublisherSpec.js | 19 |
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'); })); |