mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Fixed failed test
This commit is contained in:
@@ -2,22 +2,31 @@ import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|||||||
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { of as observableOf } from 'rxjs';
|
|
||||||
import { StoreModule } from '@ngrx/store';
|
import { StoreModule } from '@ngrx/store';
|
||||||
|
import { provideMockStore } from '@ngrx/store/testing';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
import { LogInComponent } from './log-in.component';
|
import { LogInComponent } from './log-in.component';
|
||||||
import { authReducer } from '../../core/auth/auth.reducer';
|
|
||||||
import { AuthService } from '../../core/auth/auth.service';
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
import { authMethodsMock, AuthServiceStub } from '../testing/auth-service-stub';
|
import { authMethodsMock, AuthServiceStub } from '../testing/auth-service-stub';
|
||||||
import { createTestComponent } from '../testing/utils';
|
import { createTestComponent } from '../testing/utils';
|
||||||
import { SharedModule } from '../shared.module';
|
import { SharedModule } from '../shared.module';
|
||||||
|
import { appReducers } from '../../app.reducer';
|
||||||
|
|
||||||
describe('LogInComponent', () => {
|
describe('LogInComponent', () => {
|
||||||
|
|
||||||
let component: LogInComponent;
|
let component: LogInComponent;
|
||||||
let fixture: ComponentFixture<LogInComponent>;
|
let fixture: ComponentFixture<LogInComponent>;
|
||||||
|
const initialState = {
|
||||||
|
core: {
|
||||||
|
auth: {
|
||||||
|
authenticated: false,
|
||||||
|
loaded: false,
|
||||||
|
loading: false,
|
||||||
|
authMethods: authMethodsMock
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
// refine the test module by declaring the test component
|
// refine the test module by declaring the test component
|
||||||
@@ -25,7 +34,7 @@ describe('LogInComponent', () => {
|
|||||||
imports: [
|
imports: [
|
||||||
FormsModule,
|
FormsModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
StoreModule.forRoot(authReducer),
|
StoreModule.forRoot(appReducers),
|
||||||
SharedModule,
|
SharedModule,
|
||||||
TranslateModule.forRoot()
|
TranslateModule.forRoot()
|
||||||
],
|
],
|
||||||
@@ -34,6 +43,7 @@ describe('LogInComponent', () => {
|
|||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{provide: AuthService, useClass: AuthServiceStub},
|
{provide: AuthService, useClass: AuthServiceStub},
|
||||||
|
provideMockStore({ initialState }),
|
||||||
LogInComponent
|
LogInComponent
|
||||||
],
|
],
|
||||||
schemas: [
|
schemas: [
|
||||||
@@ -71,8 +81,6 @@ describe('LogInComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(LogInComponent);
|
fixture = TestBed.createComponent(LogInComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
component.isAuthenticated = observableOf(false);
|
|
||||||
component.loading = observableOf(false);
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
@@ -82,11 +90,7 @@ describe('LogInComponent', () => {
|
|||||||
component = null;
|
component = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render a log-in container component foe each auth method available', () => {
|
it('should render a log-in container component for each auth method available', () => {
|
||||||
component.authMethods = observableOf(authMethodsMock);
|
|
||||||
|
|
||||||
fixture.detectChanges();
|
|
||||||
|
|
||||||
const loginContainers = fixture.debugElement.queryAll(By.css('ds-log-in-container'));
|
const loginContainers = fixture.debugElement.queryAll(By.css('ds-log-in-container'));
|
||||||
expect(loginContainers.length).toBe(2);
|
expect(loginContainers.length).toBe(2);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user