mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#272 Update 'login' test config
This commit is contained in:
@@ -59,7 +59,7 @@ export class AlfrescoAuthenticationService {
|
|||||||
* @param password
|
* @param password
|
||||||
* @returns {Observable<R>|Observable<T>}
|
* @returns {Observable<R>|Observable<T>}
|
||||||
*/
|
*/
|
||||||
login(username: string, password: string) {
|
login(username: string, password: string): Observable<string> {
|
||||||
return this.loginPost(username, password);
|
return this.loginPost(username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,6 +52,21 @@ System.config(config);
|
|||||||
|
|
||||||
System.import('@angular/platform-browser/src/browser/browser_adapter')
|
System.import('@angular/platform-browser/src/browser/browser_adapter')
|
||||||
.then(function(browser_adapter) { browser_adapter.BrowserDomAdapter.makeCurrent(); })
|
.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() { return Promise.all(resolveTestFiles()); })
|
||||||
.then(
|
.then(
|
||||||
function() {
|
function() {
|
||||||
|
@@ -16,11 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Observable } from 'rxjs/Rx';
|
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> {
|
login(username: string, password: string): Observable<boolean> {
|
||||||
if (username === 'fake-username' && password === 'fake-password') {
|
if (username === 'fake-username' && password === 'fake-password') {
|
||||||
return Observable.of(true);
|
return Observable.of(true);
|
||||||
@@ -28,8 +28,4 @@ export class AuthenticationMock {
|
|||||||
return Observable.throw('Fake server error');
|
return Observable.throw('Fake server error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getProviders(): Array<any> {
|
|
||||||
return [provide(AlfrescoAuthenticationService, {useValue: this})];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -15,37 +15,26 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import {
|
|
||||||
TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
|
|
||||||
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
|
|
||||||
} from '@angular/platform-browser-dynamic/testing';
|
|
||||||
import {
|
import {
|
||||||
it,
|
it,
|
||||||
describe,
|
describe,
|
||||||
expect,
|
expect,
|
||||||
inject,
|
inject,
|
||||||
beforeEachProviders,
|
beforeEachProviders
|
||||||
setBaseTestProviders
|
|
||||||
} from '@angular/core/testing';
|
} from '@angular/core/testing';
|
||||||
|
import { AlfrescoAuthenticationService } from 'ng2-alfresco-core';
|
||||||
import { TestComponentBuilder } from '@angular/compiler/testing';
|
import { TestComponentBuilder } from '@angular/compiler/testing';
|
||||||
import { provide } from '@angular/core';
|
|
||||||
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
import { AlfrescoTranslationService } from 'ng2-alfresco-core';
|
||||||
import { AlfrescoLoginComponent } from './alfresco-login.component';
|
import { AlfrescoLoginComponent } from './alfresco-login.component';
|
||||||
import { AuthenticationMock } from './../assets/authentication.service.mock';
|
import { AuthenticationMock } from './../assets/authentication.service.mock';
|
||||||
import { TranslationMock } from './../assets/translation.service.mock';
|
import { TranslationMock } from './../assets/translation.service.mock';
|
||||||
|
|
||||||
describe('AlfrescoLogin', () => {
|
describe('AlfrescoLogin', () => {
|
||||||
let authService;
|
|
||||||
|
|
||||||
setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
|
|
||||||
|
|
||||||
beforeEachProviders(() => {
|
beforeEachProviders(() => {
|
||||||
authService = new AuthenticationMock();
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
authService.getProviders(),
|
{ provide: AlfrescoAuthenticationService, useClass: AuthenticationMock },
|
||||||
provide(AlfrescoTranslationService, {useClass: TranslationMock})
|
{ provide: AlfrescoTranslationService, useClass: TranslationMock }
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user