diff options
Diffstat (limited to 'js/tests/unit/service')
-rw-r--r-- | js/tests/unit/service/ItemResourceSpec.js | 8 | ||||
-rw-r--r-- | js/tests/unit/service/LoadingSpec.js | 6 | ||||
-rw-r--r-- | js/tests/unit/service/PublisherSpec.js | 10 | ||||
-rw-r--r-- | js/tests/unit/service/ResourceSpec.js | 109 | ||||
-rw-r--r-- | js/tests/unit/service/SettingsSpec.js | 6 |
5 files changed, 64 insertions, 75 deletions
diff --git a/js/tests/unit/service/ItemResourceSpec.js b/js/tests/unit/service/ItemResourceSpec.js index 9d6c10ae0..acbf0850c 100644 --- a/js/tests/unit/service/ItemResourceSpec.js +++ b/js/tests/unit/service/ItemResourceSpec.js @@ -7,27 +7,27 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -describe('ItemResource', function () { +describe('ItemResource', () => { 'use strict'; beforeEach(module('News')); - it('should receive the newestItemId', inject(function (ItemResource) { + it('should receive the newestItemId', inject((ItemResource) => { ItemResource.receive(3, 'newestItemId'); expect(ItemResource.getNewestItemId()).toBe(3); })); - it('should receive the newestItemId', inject(function (ItemResource) { + it('should receive the newestItemId', inject((ItemResource) => { ItemResource.receive(2, 'starred'); expect(ItemResource.getStarredCount()).toBe(2); })); - it('should receive items', inject(function (ItemResource) { + it('should receive items', inject((ItemResource) => { ItemResource.receive([ { id: 3 diff --git a/js/tests/unit/service/LoadingSpec.js b/js/tests/unit/service/LoadingSpec.js index 2033f33cc..be654641c 100644 --- a/js/tests/unit/service/LoadingSpec.js +++ b/js/tests/unit/service/LoadingSpec.js @@ -7,18 +7,18 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -describe('Loading', function () { +describe('Loading', () => { 'use strict'; beforeEach(module('News')); - it('should be not load by default', inject(function (Loading) { + it('should be not load by default', inject((Loading) => { expect(Loading.isLoading('global')).toBe(false); expect(Loading.isLoading('content')).toBe(false); expect(Loading.isLoading('autopaging')).toBe(false); })); - it('should set loading', inject(function (Loading) { + it('should set loading', inject((Loading) => { Loading.setLoading('global', true); expect(Loading.isLoading('global')).toBe(true); })); diff --git a/js/tests/unit/service/PublisherSpec.js b/js/tests/unit/service/PublisherSpec.js index 06cd48c6a..38efa9398 100644 --- a/js/tests/unit/service/PublisherSpec.js +++ b/js/tests/unit/service/PublisherSpec.js @@ -7,13 +7,13 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -describe('Publisher', function () { +describe('Publisher', () => { 'use strict'; beforeEach(module('News')); - it('should should publish on all possible channels', inject(function (Publisher) { - var obj = { + it('should should publish on all possible channels', inject((Publisher) => { + let obj = { receive: jasmine.createSpy('receive') }; @@ -27,7 +27,7 @@ describe('Publisher', function () { })); - it('should should publish on all possible channels', inject(function (Publisher) { + it('should should publish on all possible channels', inject((Publisher) => { var obj = { receive: jasmine.createSpy('receive') }; @@ -42,7 +42,7 @@ describe('Publisher', function () { })); - it('should not broadcast to not subscribed channels', inject(function (Publisher) { + it('should not broadcast not subscribed channels', inject((Publisher) => { Publisher.publishAll({ test: 'tom' }); diff --git a/js/tests/unit/service/ResourceSpec.js b/js/tests/unit/service/ResourceSpec.js index ba877fcd4..ec0b95ed9 100644 --- a/js/tests/unit/service/ResourceSpec.js +++ b/js/tests/unit/service/ResourceSpec.js @@ -7,25 +7,26 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -describe('Resource', function () { +describe('Resource', () => { 'use strict'; - var childModel; + let childResource; beforeEach(module('News')); - beforeEach(inject(function (Resource) { - var ChildModel = function () { - Resource.call(this, 'id'); - }; - ChildModel.prototype = Object.create(Resource.prototype); + beforeEach(inject((Resource, $http) => { + class ChildResource extends Resource { + constructor ($http) { + super('id', $http); + } + } - childModel = new ChildModel(); + childResource = new ChildResource($http); })); - it('should receive an object', function () { - var objects = [ + it('should receive an object', () => { + let objects = [ { id: 2 }, @@ -34,118 +35,106 @@ describe('Resource', function () { } ]; - childModel.receive(objects); + childResource.receive(objects); - expect(childModel.size()).toBe(2); + expect(childResource.size()).toBe(2); }); - it('should add an object', function () { - var object = { + it('should add an object', () => { + let object = { id: 3, name: 'test' }; - childModel.add(object); + childResource.add(object); - expect(childModel.get(3)).toBe(object); + expect(childResource.get(3)).toBe(object); }); - it('should overwrite an object if it already exists', function () { - var object1, - object2; - - object1 = { + it('should overwrite an object if it already exists', () => { + let object1 = { id: 3, name: 'test', test: 'ho' }; - object2 = { + let object2 = { id: 3, name: 'test2' }; - childModel.add(object1); - childModel.add(object2); + childResource.add(object1); + childResource.add(object2); - expect(childModel.get(3).name).toBe('test2'); - expect(childModel.get(3).test).toBe('ho'); - expect(childModel.size()).toBe(1); + expect(childResource.get(3).name).toBe('test2'); + expect(childResource.get(3).test).toBe('ho'); + expect(childResource.size()).toBe(1); }); - it('should delete a Resource', function () { - var object1, - object2; - - object1 = { + it('should delete a Resource', () => { + let object1 = { id: 3, name: 'test', test: 'ho' }; - object2 = { + let object2 = { id: 4, name: 'test2' }; - childModel.add(object1); - childModel.add(object2); + childResource.add(object1); + childResource.add(object2); - childModel.delete(3); + childResource.delete(3); - expect(childModel.get(3)).not.toBeDefined(); - expect(childModel.get(4).name).toBe('test2'); - expect(childModel.size()).toBe(1); + expect(childResource.get(3)).not.toBeDefined(); + expect(childResource.get(4).name).toBe('test2'); + expect(childResource.size()).toBe(1); }); - it('should clear all models', function () { - var object1, - object2; - - object1 = { + it('should clear all models', () => { + let object1 = { id: 3, name: 'test', test: 'ho' }; - object2 = { + let object2 = { id: 4, name: 'test2' }; - childModel.add(object1); - childModel.add(object2); + childResource.add(object1); + childResource.add(object2); - childModel.clear(); + childResource.clear(); - expect(childModel.get(3)).not.toBeDefined(); - expect(childModel.get(4)).not.toBeDefined(); - expect(childModel.size()).toBe(0); + expect(childResource.get(3)).not.toBeDefined(); + expect(childResource.get(4)).not.toBeDefined(); + expect(childResource.size()).toBe(0); }); - it('should get all models', function () { - var object1, - object2; - - object1 = { + it('should get all models', () => { + let object1 = { id: 3, name: 'test', test: 'ho' }; - object2 = { + let object2 = { id: 4, name: 'test2' }; - childModel.add(object1); - childModel.add(object2); + childResource.add(object1); + childResource.add(object2); - expect(childModel.getAll()[1].id).toBe(4); + expect(childResource.getAll()[1].id).toBe(4); }); });
\ No newline at end of file diff --git a/js/tests/unit/service/SettingsSpec.js b/js/tests/unit/service/SettingsSpec.js index 65dc4bf2f..b76251e3a 100644 --- a/js/tests/unit/service/SettingsSpec.js +++ b/js/tests/unit/service/SettingsSpec.js @@ -7,12 +7,12 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -describe('Settings', function () { +describe('Settings', () => { 'use strict'; beforeEach(module('News')); - it('should receive default settings', inject(function (Settings) { + it('should receive default settings', inject((Settings) => { Settings.receive({ 'showAll': true }); @@ -21,7 +21,7 @@ describe('Settings', function () { })); - it('should set values', inject(function (Settings) { + it('should set values', inject((Settings) => { Settings.set('showAll', true); expect(Settings.get('showAll')).toBe(true); |