Gets signed-in state from API
This commit is contained in:
parent
c46385ea29
commit
927356da9d
|
@ -1,2 +1,2 @@
|
|||
<app-sign-in *ngIf="!isSignedIn()"></app-sign-in>
|
||||
<app-workflow-spec-list *ngIf="isSignedIn()"></app-workflow-spec-list>
|
||||
<app-sign-in *ngIf="!isSignedIn"></app-sign-in>
|
||||
<app-workflow-spec-list *ngIf="isSignedIn"></app-workflow-spec-list>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import {Component, NO_ERRORS_SCHEMA} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {HttpClientTestingModule} from '@angular/common/http/testing';
|
||||
import {Component} from '@angular/core';
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
import {MockEnvironment} from 'sartography-workflow-lib';
|
||||
import {ApiService, MockEnvironment} from 'sartography-workflow-lib';
|
||||
|
||||
import {HomeComponent} from './home.component';
|
||||
|
||||
|
@ -9,13 +11,15 @@ import {HomeComponent} from './home.component';
|
|||
selector: 'app-sign-in',
|
||||
template: ''
|
||||
})
|
||||
class MockSignInComponent {}
|
||||
class MockSignInComponent {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-workflow-spec-list',
|
||||
template: ''
|
||||
})
|
||||
class MockWorkflowSpecListComponent {}
|
||||
class MockWorkflowSpecListComponent {
|
||||
}
|
||||
|
||||
describe('HomeComponent', () => {
|
||||
let component: HomeComponent;
|
||||
|
@ -28,8 +32,16 @@ describe('HomeComponent', () => {
|
|||
MockSignInComponent,
|
||||
MockWorkflowSpecListComponent,
|
||||
],
|
||||
imports: [
|
||||
HttpClientTestingModule
|
||||
],
|
||||
providers: [
|
||||
HttpClient,
|
||||
ApiService,
|
||||
{provide: 'APP_ENVIRONMENT', useClass: MockEnvironment},
|
||||
]
|
||||
})
|
||||
.compileComponents();
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -43,7 +55,7 @@ describe('HomeComponent', () => {
|
|||
});
|
||||
|
||||
it('should check signed-in state', () => {
|
||||
const result = component.isSignedIn();
|
||||
const result = component.isSignedIn;
|
||||
expect(result).toBeDefined();
|
||||
expect(typeof result).toEqual('boolean');
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import {Component} from '@angular/core';
|
||||
import {isSignedIn} from 'sartography-workflow-lib';
|
||||
import {ApiService, isSignedIn} from 'sartography-workflow-lib';
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
|
@ -7,9 +7,11 @@ import {isSignedIn} from 'sartography-workflow-lib';
|
|||
styleUrls: ['./home.component.scss']
|
||||
})
|
||||
export class HomeComponent {
|
||||
isSignedIn = isSignedIn;
|
||||
|
||||
constructor() {
|
||||
constructor(private apiService: ApiService) {
|
||||
}
|
||||
|
||||
get isSignedIn(): boolean {
|
||||
return this.apiService.isSignedIn();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue