diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-21 23:43:28 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-21 23:43:28 +0200 |
commit | 0fa67552247b2d29a6ca438c2605b8db2bbdbab7 (patch) | |
tree | 8109135e2fc141a324e8f21c66243ee4277b3b7c /js/tests | |
parent | d3a774b2bd79654360a3ef12618102abf85a2ce3 (diff) |
es6 all the things
Diffstat (limited to 'js/tests')
-rw-r--r-- | js/tests/e2e/main.js | 7 | ||||
-rw-r--r-- | js/tests/unit/controller/AppControllerSpec.js | 14 | ||||
-rw-r--r-- | js/tests/unit/controller/ContentControllerSpec.js | 8 | ||||
-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 | ||||
-rw-r--r-- | js/tests/unit/stubs/App.js (renamed from js/tests/unit/stubs/app.js) | 7 | ||||
-rw-r--r-- | js/tests/unit/stubs/OC.js (renamed from js/tests/unit/stubs/oc.js) | 4 |
10 files changed, 85 insertions, 94 deletions
diff --git a/js/tests/e2e/main.js b/js/tests/e2e/main.js index b76110c65..247deb47b 100644 --- a/js/tests/e2e/main.js +++ b/js/tests/e2e/main.js @@ -23,12 +23,9 @@ describe('news page', function () { it('should show the first run page', function () { - var firstRun; - - - firstRun = browser.findElement(By.id('first-run')); + let firstRun = browser.findElement(By.id('first-run')); //firstRun.findElement(By.tagName('h1')).then(function (greeting) { - // expect(greeting.getText()).toBe('Welcome to the ownCloud News app!'); + //expect(greeting.getText()).toBe('Welcome to the ownCloud News app!'); //}); expect(firstRun.isDisplayed()).toBe(true); diff --git a/js/tests/unit/controller/AppControllerSpec.js b/js/tests/unit/controller/AppControllerSpec.js index d44d8b0c3..fc5780a40 100644 --- a/js/tests/unit/controller/AppControllerSpec.js +++ b/js/tests/unit/controller/AppControllerSpec.js @@ -7,36 +7,36 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -describe('AppController', function () { +describe('AppController', () => { 'use strict'; - var controller; + let controller; beforeEach(module('News')); - beforeEach(inject(function ($controller) { + beforeEach(inject(($controller) => { controller = $controller('AppController'); })); - it('should expose Loading', inject(function (Loading) { + it('should expose Loading', inject((Loading) => { expect(controller.loading).toBe(Loading); })); - it('should expose set firstrun if no feeds and folders', inject(function () { + it('should expose set firstrun if no feeds and folders', inject(() => { expect(controller.isFirstRun()).toBe(true); })); - it('should expose set firstrun if feeds', inject(function (FeedResource) { + it('should expose set firstrun if feeds', inject((FeedResource) => { FeedResource.add({url: 'test'}); expect(controller.isFirstRun()).toBe(false); })); - it('should expose set firstrun if folders', inject(function (FolderResource) { + it('should expose set firstrun if folders', inject((FolderResource) => { FolderResource.add({name: 'test'}); expect(controller.isFirstRun()).toBe(false); diff --git a/js/tests/unit/controller/ContentControllerSpec.js b/js/tests/unit/controller/ContentControllerSpec.js index c99cb79ab..1dbd3d936 100644 --- a/js/tests/unit/controller/ContentControllerSpec.js +++ b/js/tests/unit/controller/ContentControllerSpec.js @@ -7,19 +7,19 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -describe('ContentController', function () { +describe('ContentController', () => { 'use strict'; beforeEach(module('News')); - it('should publish data to models', inject(function ($controller, Publisher, - FeedResource, ItemResource) { + it('should publish data to models', inject(($controller, Publisher, + FeedResource, ItemResource) => { Publisher.subscribe(ItemResource).toChannels('items'); Publisher.subscribe(FeedResource).toChannels('feeds'); - var controller = $controller('ContentController', { + let controller = $controller('ContentController', { data: { 'items': [ { 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); diff --git a/js/tests/unit/stubs/app.js b/js/tests/unit/stubs/App.js index 3cb1b1d3f..dc512f5e1 100644 --- a/js/tests/unit/stubs/app.js +++ b/js/tests/unit/stubs/App.js @@ -7,4 +7,9 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2012, 2014 */ -var app = angular.module('News', ['ngRoute', 'ngSanitize', 'ngAnimate', 'ngMock']);
\ No newline at end of file +window.app = angular.module('News', [ + 'ngRoute', + 'ngSanitize', + 'ngAnimate', + 'ngMock' +]);
\ No newline at end of file diff --git a/js/tests/unit/stubs/oc.js b/js/tests/unit/stubs/OC.js index 07ac96491..82622aab5 100644 --- a/js/tests/unit/stubs/oc.js +++ b/js/tests/unit/stubs/OC.js @@ -7,8 +7,8 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2012, 2014 */ -var OC = { - generateUrl: function () { +window.OC = { + generateUrl: () => { 'use strict'; return ''; |