diff --git a/frontend/app/model/autehentication.service.spec.ts b/frontend/app/model/autehentication.service.spec.ts index 15beb580..ad6cca87 100644 --- a/frontend/app/model/autehentication.service.spec.ts +++ b/frontend/app/model/autehentication.service.spec.ts @@ -8,26 +8,30 @@ import { TestComponentBuilder } from 'angular2/testing'; -import {Component, provide} from 'angular2/core'; -import {AuthenticationService} from "../../../frontend/app/model/authentication.service"; +import {provide} from 'angular2/core'; +import {AuthenticationService} from "./authentication.service"; import {UserService} from "./user.service"; +import {User} from "../../../common/entities/User"; +import {Message} from "../../../common/entities/Message"; +import "rxjs/Rx"; +import {LoginCredential} from "../../../common/entities/LoginCredential"; - +class MockUserService { + public login(credential:LoginCredential){ + return Promise.resolve(new Message(null,new User())) + } +} describe('LoginService', () => { beforeEachProviders(() => [ - provide(UserService, { - useFactory: function() { - return {login() {}}; - } - }), - + provide(UserService, {useClass: MockUserService}), AuthenticationService ]); it('should call User service login', inject([ AuthenticationService,UserService ], (authService, userService) => { - spyOn(userService,"login"); + spyOn(userService,"login").and.callThrough(); + expect(userService.login).not.toHaveBeenCalled(); authService.login(); expect(userService.login).toHaveBeenCalled(); diff --git a/package.json b/package.json index 992e2809..73e927f4 100644 --- a/package.json +++ b/package.json @@ -21,16 +21,16 @@ "url": "https://github.com/bpatrik/PiGallery2/issues" }, "dependencies": { - "angular2": "^2.0.0-beta.10", + "angular2": "^2.0.0-beta.11", + "core-js": "^2.2.1", "debug": "^2.2.0", "es6-promise": "^3.1.2", - "es6-shim": "^0.33.13", + "es6-shim": "^0.35.0", "es7-reflect-metadata": "^1.6.0", "express": "^4.13.4", "express-session": "^1.13.0", - "karma-jasmine": "^0.3.8", "morgan": "^1.7.0", - "protractor": "^3.2.0", + "protractor": "^3.2.1", "reflect-metadata": "0.1.2", "rxjs": "^5.0.0-beta.2", "ts-loader": "^0.8.1", @@ -41,7 +41,6 @@ "zone.js": "^0.6.4" }, "devDependencies": { - "awesome-typescript-loader": "^0.16.0-rc.0", "compression-webpack-plugin": "^0.3.0", "copy-webpack-plugin": "^1.1.1", "css-loader": "^0.23.1", @@ -65,7 +64,6 @@ "karma-sourcemap-loader": "^0.3.7", "karma-webpack": "1.7.0", "ng2lint": "0.0.10", - "phantomjs-polyfill": "0.0.2", "phantomjs-prebuilt": "^2.1.4", "protractor": "^3.1.1", "raw-loader": "0.5.1", @@ -78,7 +76,6 @@ "tslint": "^3.5.0", "tslint-loader": "^2.1.3", "typedoc": "^0.3.12", - "typescript": "~1.8.7", "url-loader": "^0.5.7", "webpack": "^1.12.14" }, diff --git a/test/spec-bundle.js b/test/spec-bundle.js index 33b6d5c6..45c51f71 100644 --- a/test/spec-bundle.js +++ b/test/spec-bundle.js @@ -9,16 +9,12 @@ * all here! Crazy huh. So we need to do some setup */ Error.stackTraceLimit = Infinity; -require('phantomjs-polyfill'); -require('es6-promise'); -require('es6-shim'); -require('es7-reflect-metadata'); +require('core-js'); -require('zone.js/dist/zone-microtask.js'); +require('zone.js/dist/zone.js'); require('zone.js/dist/long-stack-trace-zone.js'); require('zone.js/dist/jasmine-patch.js'); - var testing = require('angular2/testing'); var browser = require('angular2/platform/testing/browser'); diff --git a/test/src-bundle.js b/test/src-bundle.js index f34228bd..628fd8a3 100644 --- a/test/src-bundle.js +++ b/test/src-bundle.js @@ -9,12 +9,10 @@ * all here! Crazy huh. So we need to do some setup */ Error.stackTraceLimit = Infinity; -require('phantomjs-polyfill'); -require('es6-promise'); -require('es6-shim'); -require('es7-reflect-metadata'); +// Prefer CoreJS over the polyfills above +require('core-js'); -require('zone.js/dist/zone-microtask.js'); +require('zone.js/dist/zone.js'); require('zone.js/dist/long-stack-trace-zone.js'); require('zone.js/dist/jasmine-patch.js'); diff --git a/test/webpack.test.config.js b/test/webpack.test.config.js index 1df28830..49c36b99 100644 --- a/test/webpack.test.config.js +++ b/test/webpack.test.config.js @@ -34,7 +34,7 @@ module.exports = { loaders: [ { test: /\.ts$/, - loader: 'awesome-typescript-loader', + loader: 'ts-loader', query: { "compilerOptions": { "removeComments": true