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
| class MockComponent implements CanDeactivateGuarded { | |
| // Set this to the value you want to mock being returned from GuardedComponent | |
| returnValue: boolean | Observable<boolean>; | |
| canDeactivate(): boolean | Observable<boolean> { | |
| return this.returnValue; | |
| } | |
| } |
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 { CanDeactivate } from '@angular/router'; | |
| import { Component } from '@angular/core'; | |
| import { Observable } from 'rxjs'; | |
| export interface CanDeactivateGuarded { | |
| canDeactivate: () => boolean | Observable<boolean>; | |
| } |
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 } from '@angular/core/testing'; | |
| import { CanDeactivateGuardService } from './can-deactivate-guard.service'; | |
| import { CanDeactivate } from '@angular/router'; | |
| import { Observable, Subject } from 'rxjs'; | |
| import { CanDeactivateGuarded } from './can-deactivate-guarded'; | |
| class MockComponent implements CanDeactivateGuarded { | |
| // Set this to the value you want to mock being returned from GuardedComponent | |
| returnValue: boolean | Observable<boolean>; |
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 { Logger } from './logger'; | |
| import { environment } from '@environments/environment'; | |
| describe('Logger Spec', () => { | |
| let debug; | |
| let info; | |
| let warn; | |
| let err; | |
| let log; |
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'; | |
| import { environment } from '@environments/environment'; | |
| /** | |
| * Class of static methods to allow for consistent console logging. | |
| * @export | |
| */ | |
| @Injectable({ | |
| providedIn: 'root' |
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
| export function MyDecorator(target: any) { | |
| // save a reference to the original constructor | |
| var original = target; | |
| // a utility function to generate instances of a class | |
| function construct(constructor, args) { | |
| let c: any = () => { | |
| return constructor.apply(this, args); | |
| }; | |
| c.prototype = constructor.prototype; |
NewerOlder