mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-12 12:33:07 +00:00
Finalized auth module
This commit is contained in:
@@ -1,25 +1,25 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
import { CUSTOM_ELEMENTS_SCHEMA, DebugElement } from "@angular/core";
|
||||
import { ComponentFixture, TestBed, async } from "@angular/core/testing";
|
||||
import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||
import { MaterialModule } from "@angular/material";
|
||||
import { By } from "@angular/platform-browser";
|
||||
import { Store, StoreModule } from "@ngrx/store";
|
||||
import { go } from "@ngrx/router-store";
|
||||
/*import { CUSTOM_ELEMENTS_SCHEMA, DebugElement } from '@angular/core';
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MaterialModule } from '@angular/material';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Store, StoreModule } from '@ngrx/store';
|
||||
import { go } from '@ngrx/router-store';
|
||||
|
||||
// reducers
|
||||
import { reducer } from "../../app.reducers";
|
||||
import { reducer } from '../../app.reducers';
|
||||
|
||||
// models
|
||||
import { User } from "../../core/models/user";
|
||||
import { User } from '../../core/models/user';
|
||||
|
||||
// services
|
||||
import { MOCK_USER } from "../../core/services/user.service";
|
||||
import { MOCK_USER } from '../../core/services/user.service';
|
||||
|
||||
// this component to test
|
||||
import { LogInComponent } from "./log-in.component";
|
||||
import { LogInComponent } from './log-in.component';
|
||||
|
||||
describe("LogInComponent", () => {
|
||||
describe('LogInComponent', () => {
|
||||
|
||||
let component: LogInComponent;
|
||||
let fixture: ComponentFixture<LogInComponent>;
|
||||
@@ -65,23 +65,23 @@ describe("LogInComponent", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("should create a FormGroup comprised of FormControls", () => {
|
||||
it('should create a FormGroup comprised of FormControls', () => {
|
||||
fixture.detectChanges();
|
||||
expect(component.form instanceof FormGroup).toBe(true);
|
||||
});
|
||||
|
||||
it("should authenticate", () => {
|
||||
it('should authenticate', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
// set FormControl values
|
||||
component.form.controls["email"].setValue(user.email);
|
||||
component.form.controls["password"].setValue(user.password);
|
||||
component.form.controls['email'].setValue(user.email);
|
||||
component.form.controls['password'].setValue(user.password);
|
||||
|
||||
// submit form
|
||||
component.submit();
|
||||
|
||||
// verify Store.dispatch() is invoked
|
||||
expect(page.navigateSpy.calls.any()).toBe(true, "Store.dispatch not invoked");
|
||||
expect(page.navigateSpy.calls.any()).toBe(true, 'Store.dispatch not invoked');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -90,6 +90,7 @@ describe("LogInComponent", () => {
|
||||
*
|
||||
* @class Page
|
||||
*/
|
||||
/*
|
||||
class Page {
|
||||
|
||||
public emailInput: HTMLInputElement;
|
||||
@@ -102,15 +103,16 @@ class Page {
|
||||
const store = injector.get(Store);
|
||||
|
||||
// add spies
|
||||
this.navigateSpy = spyOn(store, "dispatch");
|
||||
this.navigateSpy = spyOn(store, 'dispatch');
|
||||
}
|
||||
|
||||
public addPageElements() {
|
||||
const emailInputSelector = "input[formcontrolname=\"email\"]";
|
||||
const emailInputSelector = 'input[formcontrolname=\'email\']';
|
||||
// console.log(this.fixture.debugElement.query(By.css(emailInputSelector)));
|
||||
this.emailInput = this.fixture.debugElement.query(By.css(emailInputSelector)).nativeElement;
|
||||
|
||||
const passwordInputSelector = "input[formcontrolname=\"password\"]";
|
||||
const passwordInputSelector = 'input[formcontrolname=\'password\']';
|
||||
this.passwordInput = this.fixture.debugElement.query(By.css(passwordInputSelector)).nativeElement;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user