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 { ReplaySubject } from 'rxjs/ReplaySubject'; | |
| @Injectable() | |
| export class PopupService { | |
| private popupDialog = new ReplaySubject<{popupEvent: string, component?, options?: {}}>(); | |
| public popupDialog$ = this.popupDialog.asObservable(); |
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 { PopupService } from './popup.service'; | |
| import { SignInComponent } from '../components/signin/signin.component'; | |
| describe('PopupService', () => { | |
| let service: PopupService; | |
| // create PopupService instance | |
| beforeEach(() => { service = new PopupService(); }); | |
| // we need 'done' to avoid test finishing before date was received | |
| it('subscribe for opening works', (done: DoneFn) => { | |
| service.open(SignInComponent, [{title: 'Попап заголовок', message: 'Успешно'}]); |
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 } from '@angular/core'; | |
| @Component({ | |
| selector: 'app-root', | |
| template: '<h1> Welcome to {{ title }}!</h1>', | |
| styleUrls: ['./app.component.css'] | |
| }) | |
| export class AppComponent { | |
| title = 'app'; | |
| } |
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
| beforeEach(async(() => { | |
| TestBed.configureTestingModule({ | |
| declarations: [ | |
| AppComponent | |
| ], | |
| }).compileComponents(); | |
| })); |
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
| beforeEach(() => { | |
| fixture = TestBed.createComponent(AppComponent); | |
| comp = fixture.componentInstance; | |
| }); |
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
| it('should create the comp', => { | |
| expect(comp).toBeTruthy(); | |
| }); | |
| it(`should have as title 'app'`, () => { | |
| expect(comp.title).toEqual('app'); | |
| }); |
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
| it('should render title in a h1 tag', () => { | |
| fixture.detectChanges(); | |
| const compiled = fixture.debugElement.nativeElement; | |
| expect(compiled.querySelector('h1').textContent) | |
| .toContain('Welcome to app!'); | |
| }); |
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 class AppComponent { | |
| constructor(private popup: PopupService) { } | |
| title = 'app'; | |
| } |
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
| TestBed.configureTestingModule({ | |
| declarations: [ | |
| AppComponent | |
| ], | |
| providers: [PopupService] | |
| }); |
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
| const popupServiceStub = { | |
| open: () => {} | |
| }; |
OlderNewer