This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { TestBed, tick, fakeAsync } from '@angular/core/testing'; | |
| import { UserAsyncComponent } from './user-async.component'; | |
| import { UserAsyncService } from './user-async.service'; | |
| import { Observable, Observer } from 'rxjs'; | |
| describe('User Async Component:', () => { | |
| beforeEach(async () => { | |
| TestBed.configureTestingModule({ | |
| declarations: [UserAsyncComponent] | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component, OnInit } from '@angular/core'; | |
| import { UserAsyncService } from './user-async.service'; | |
| import { Observable } from 'rxjs'; | |
| @Component({ | |
| selector: 'app-user-async', | |
| templateUrl: './user-async.component.html', | |
| styleUrls: ['./user-async.component.scss'], | |
| providers: [UserAsyncService] | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <p *ngIf="systemError">{{systemErrorMessage}}</p> | |
| <div *ngIf="isLoggedIn && !systemError"> | |
| <p> | |
| {{userDetail.name}} | |
| </p> | |
| <p>Note: Above user details returned by async call.</p> | |
| </div> | |
| <div *ngIf="!isLoggedIn && !systemError"> | |
| <p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { async, TestBed } from '@angular/core/testing'; | |
| import { UserComponent } from './user.component'; | |
| import { UserService } from './user.service'; | |
| describe('UserComponent', () => { | |
| beforeEach(async(() => { | |
| TestBed.configureTestingModule({ | |
| declarations: [UserComponent] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Injectable } from '@angular/core'; | |
| @Injectable() | |
| export class UserService { | |
| user = { | |
| name: 'Mannie' | |
| }; | |
| getUser() { | |
| return this.user; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component, OnInit } from '@angular/core'; | |
| import { UserService } from './user.service'; | |
| @Component({ | |
| selector: 'app-user', | |
| templateUrl: './user.component.html', | |
| styleUrls: ['./user.component.scss'], | |
| providers: [UserService] | |
| }) | |
| export class UserComponent implements OnInit { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div *ngIf="isUserLoggedIn"> | |
| <p> | |
| Welcome {{user.name}} | |
| </p> | |
| </div> | |
| <div *ngIf="!isUserLoggedIn"> | |
| <p> | |
| user is NOT logged In. | |
| </p> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { TestBed, async } from '@angular/core/testing'; | |
| import { AppComponent } from './app.component'; | |
| import { UserComponent } from './user/user.component'; | |
| import { UserAsyncComponent } from './user-async/user-async.component'; | |
| describe('App component', () => { | |
| beforeEach(async(() => { | |
| // The TestBed is the most important of the Angular testing utilities. | |
| // The TestBed creates a dynamically-constructed Angular test module that emulates an Angular @NgModule. | |
| // The TestBed.configureTestingModule() method takes a metadata object that can have most of the properties of an @NgModule. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component, OnInit } from '@angular/core'; | |
| @Component({ | |
| selector: 'app-root', | |
| templateUrl: './app.component.html', | |
| styleUrls: ['./app.component.scss'] | |
| }) | |
| export class AppComponent implements OnInit { | |
| title = 'Angular7-unit-testing!'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!--The content below is only a placeholder and can be replaced.--> | |
| <div style="text-align:center"> | |
| <h1> | |
| Welcome to {{ title }}! | |
| </h1> | |
| <app-user></app-user> | |
| <br> | |
| <app-user-async></app-user-async> | |
| </div> |