From d39e41496297c053623aabdfc064e494b4361da5 Mon Sep 17 00:00:00 2001 From: Aaron Louie Date: Mon, 24 Feb 2020 16:43:03 -0500 Subject: [PATCH] Fixes broken unit tests. Updates sartography-workflow-lib. --- package-lock.json | 6 +++--- package.json | 2 +- src/app/app.component.scss | 7 +++++++ src/app/app.component.spec.ts | 12 ++++++++++- src/app/home/home.component.spec.ts | 31 +++++++++++++++++++++++++--- src/app/sign-in/sign-in.component.ts | 5 ++++- 6 files changed, 54 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index dea8929..b7efd61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11641,9 +11641,9 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "sartography-workflow-lib": { - "version": "0.0.46", - "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.46.tgz", - "integrity": "sha512-gxm3mfSyQ/g9Axen4w0HAH+s3mQARVANN5KfPQZgSnvT1wP/ymnhZDikg/hfbUJQZ5qwMv+phKK53HeAsexU3w==", + "version": "0.0.48", + "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.48.tgz", + "integrity": "sha512-HeqzSbbt5J9S3FulBCUEYogXIRPkkTwnhViaxd6zEzpMDebZEt6FMCBXjVZ8e+x0griL66RNCvWzh4EXRmOkqA==", "requires": { "tslib": "^1.9.0" } diff --git a/package.json b/package.json index cef6b7e..b40d600 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "file-saver": "^2.0.2", "hammerjs": "^2.0.8", "rxjs": "~6.5.4", - "sartography-workflow-lib": "^0.0.46", + "sartography-workflow-lib": "^0.0.48", "tslib": "^1.10.0", "uuid": "^3.4.0", "zone.js": "~0.9.1" diff --git a/src/app/app.component.scss b/src/app/app.component.scss index e69de29..e25ee2c 100644 --- a/src/app/app.component.scss +++ b/src/app/app.component.scss @@ -0,0 +1,7 @@ +#globalHeader { + position: fixed; + top: 0; + left: 0; + right: 0; + z-index: 2; +} diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index b10f88d..890d34b 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -1,8 +1,12 @@ import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {MatIconModule} from '@angular/material/icon'; +import {MatMenuModule} from '@angular/material/menu'; import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; import {RouterTestingModule} from '@angular/router/testing'; import {AppComponent} from './app.component'; +import {FooterComponent} from './footer/footer.component'; +import {NavbarComponent} from './navbar/navbar.component'; describe('AppComponent', () => { let component: AppComponent; @@ -10,9 +14,15 @@ describe('AppComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [AppComponent], + declarations: [ + AppComponent, + FooterComponent, + NavbarComponent + ], imports: [ BrowserAnimationsModule, + MatIconModule, + MatMenuModule, RouterTestingModule, ] }) diff --git a/src/app/home/home.component.spec.ts b/src/app/home/home.component.spec.ts index 490e81b..027c50a 100644 --- a/src/app/home/home.component.spec.ts +++ b/src/app/home/home.component.spec.ts @@ -1,6 +1,21 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import {Component, NO_ERRORS_SCHEMA} from '@angular/core'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; +import {MockEnvironment} from 'sartography-workflow-lib'; -import { HomeComponent } from './home.component'; +import {HomeComponent} from './home.component'; + + +@Component({ + selector: 'app-sign-in', + template: '' +}) +class MockSignInComponent {} + +@Component({ + selector: 'app-workflow-spec-list', + template: '' +}) +class MockWorkflowSpecListComponent {} describe('HomeComponent', () => { let component: HomeComponent; @@ -8,7 +23,11 @@ describe('HomeComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ HomeComponent ] + declarations: [ + HomeComponent, + MockSignInComponent, + MockWorkflowSpecListComponent, + ], }) .compileComponents(); })); @@ -22,4 +41,10 @@ describe('HomeComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('should check signed-in state', () => { + const result = component.isSignedIn(); + expect(result).toBeDefined(); + expect(typeof result).toEqual('boolean'); + }); }); diff --git a/src/app/sign-in/sign-in.component.ts b/src/app/sign-in/sign-in.component.ts index e4ee66d..699a12b 100644 --- a/src/app/sign-in/sign-in.component.ts +++ b/src/app/sign-in/sign-in.component.ts @@ -1,3 +1,4 @@ +import {PlatformLocation} from '@angular/common'; import {Component, Inject, OnInit} from '@angular/core'; import {FormGroup} from '@angular/forms'; import {Router} from '@angular/router'; @@ -56,7 +57,8 @@ export class SignInComponent implements OnInit { constructor( @Inject('APP_ENVIRONMENT') private environment: AppEnvironment, private router: Router, - private api: ApiService + private api: ApiService, + private platformLocation: PlatformLocation ) { } @@ -70,6 +72,7 @@ export class SignInComponent implements OnInit { // For testing purposes, create a user to simulate login. if (!this.environment.production) { + this.model.redirect_url = this.platformLocation.href + 'session'; this.api.openSession(this.model); } else { this.error = new Error('This feature does not work in production.');