#272 Update 'login' test config

This commit is contained in:
Denys Vuika
2016-06-24 10:29:44 +01:00
parent 709ecc6f10
commit c3904f3f2f
4 changed files with 23 additions and 23 deletions

View File

@@ -59,7 +59,7 @@ export class AlfrescoAuthenticationService {
* @param password
* @returns {Observable<R>|Observable<T>}
*/
login(username: string, password: string) {
login(username: string, password: string): Observable<string> {
return this.loginPost(username, password);
}

View File

@@ -52,6 +52,21 @@ System.config(config);
System.import('@angular/platform-browser/src/browser/browser_adapter')
.then(function(browser_adapter) { browser_adapter.BrowserDomAdapter.makeCurrent(); })
.then(function () {
return Promise.all([
System.import('@angular/core/testing'),
System.import('@angular/platform-browser-dynamic/testing')
])
})
.then(function (providers) {
var testing = providers[0];
var testingBrowser = providers[1];
testing.setBaseTestProviders(
testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
})
.then(function() { return Promise.all(resolveTestFiles()); })
.then(
function() {

View File

@@ -16,11 +16,11 @@
*/
import { Observable } from 'rxjs/Rx';
import { provide } from '@angular/core';
import { AlfrescoAuthenticationService } from 'ng2-alfresco-core';
export class AuthenticationMock {
// TODO: should be extending AlfrescoAuthenticationService
export class AuthenticationMock /*extends AlfrescoAuthenticationService*/ {
// TODO: real auth service returns Observable<string>
login(username: string, password: string): Observable<boolean> {
if (username === 'fake-username' && password === 'fake-password') {
return Observable.of(true);
@@ -28,8 +28,4 @@ export class AuthenticationMock {
return Observable.throw('Fake server error');
}
}
getProviders(): Array<any> {
return [provide(AlfrescoAuthenticationService, {useValue: this})];
}
}

View File

@@ -15,37 +15,26 @@
* limitations under the License.
*/
import {
TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
} from '@angular/platform-browser-dynamic/testing';
import {
it,
describe,
expect,
inject,
beforeEachProviders,
setBaseTestProviders
beforeEachProviders
} from '@angular/core/testing';
import { AlfrescoAuthenticationService } from 'ng2-alfresco-core';
import { TestComponentBuilder } from '@angular/compiler/testing';
import { provide } from '@angular/core';
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
import { AlfrescoLoginComponent } from './alfresco-login.component';
import { AuthenticationMock } from './../assets/authentication.service.mock';
import { TranslationMock } from './../assets/translation.service.mock';
describe('AlfrescoLogin', () => {
let authService;
setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
beforeEachProviders(() => {
authService = new AuthenticationMock();
return [
authService.getProviders(),
provide(AlfrescoTranslationService, {useClass: TranslationMock})
{ provide: AlfrescoAuthenticationService, useClass: AuthenticationMock },
{ provide: AlfrescoTranslationService, useClass: TranslationMock }
];
});