Changeset View
Changeset View
Standalone View
Standalone View
src/app/_shared/notifcations/notifications.component.spec.ts
- This file was copied from src/app/notification/notification.component.spec.ts.
import { By } from '@angular/platform-browser'; | import { By } from '@angular/platform-browser'; | ||||
import { ComponentFixture, ComponentFixtureAutoDetect, TestBed, async } from '@angular/core/testing'; | import { ComponentFixture, ComponentFixtureAutoDetect, TestBed, async } from '@angular/core/testing'; | ||||
import { NO_ERRORS_SCHEMA, Component } from '@angular/core'; | import { NO_ERRORS_SCHEMA, Component } from '@angular/core'; | ||||
import { MatCardModule, MatTabsModule, MatDialogModule, MatProgressSpinnerModule, MatSnackBarModule } from '@angular/material'; | import { MatCardModule, MatTabsModule, MatDialogModule, MatProgressSpinnerModule, MatSnackBarModule } from '@angular/material'; | ||||
import { Router, ActivatedRoute, RouterModule } from '@angular/router'; | import { Router, ActivatedRoute, RouterModule } from '@angular/router'; | ||||
import { Observable } from 'rxjs'; | import { Observable } from 'rxjs'; | ||||
import { Author } from '../_models/author'; | import { Author } from '../../_models/author'; | ||||
import { Comment } from '../_models/comment'; | import { Comment } from '../../_models/comment'; | ||||
import { Notification } from '../_models/notification'; | import { Notification } from '../../_models/notification'; | ||||
import { NotificationPost } from '../_models/notificationPost'; | import { NotificationPost } from '../../_models/notificationPost'; | ||||
import { Post } from '../_models/post'; | import { Post } from '../../_models/post'; | ||||
import { SuperNotification } from '../_models/superNotification'; | import { SuperNotification } from '../../_models/superNotification'; | ||||
import { AuthenticationService } from '../_services/authentication.service'; | import { AuthenticationService } from '../../_services/authentication.service'; | ||||
import { NotificationService } from '../_services/notification.service'; | import { NotificationService } from '../../_services/notification.service'; | ||||
import { RouteService } from '../_services/route.service'; | import { RouteService } from '../../_services/route.service'; | ||||
import { NavBarService } from '../_services/navBar.service'; | import { NavBarService } from '../../_services/navBar.service'; | ||||
import { NotificationComponent } from './notification.component'; | import { NotificationsComponent } from './notifications.component'; | ||||
import { NgxPaginationModule } from 'ngx-pagination'; | import { NgxPaginationModule } from 'ngx-pagination'; | ||||
describe('NotificationComponent', () => { | describe('NotificationComponent', () => { | ||||
let comp: NotificationComponent; | let comp: NotificationsComponent; | ||||
let fixture: ComponentFixture<NotificationComponent>; | let fixture: ComponentFixture<NotificationsComponent>; | ||||
beforeEach(() => { | beforeEach(() => { | ||||
const routerStub = { | const routerStub = { | ||||
url: '/notifications' | url: '/notifications' | ||||
}; | }; | ||||
const authenticationServiceStub = { | const authenticationServiceStub = { | ||||
token: 'token' | token: 'token' | ||||
}; | }; | ||||
Show All 11 Lines | beforeEach(() => { | ||||
new Author(0, '', '', '', false), 'test'), | new Author(0, '', '', '', false), 'test'), | ||||
new Array<number>(0))) | new Array<number>(0))) | ||||
)); | )); | ||||
} | } | ||||
}; | }; | ||||
const routeServiceStub = {}; | const routeServiceStub = {}; | ||||
TestBed.configureTestingModule({ | TestBed.configureTestingModule({ | ||||
declarations: [ NotificationComponent ], | declarations: [ NotificationsComponent ], | ||||
providers: [ | providers: [ | ||||
{ provide: Router, useValue: routerStub }, | { provide: Router, useValue: routerStub }, | ||||
{ provide: ActivatedRoute, useValue: activatedRouteStub }, | { provide: ActivatedRoute, useValue: activatedRouteStub }, | ||||
{ provide: AuthenticationService, useValue: authenticationServiceStub }, | { provide: AuthenticationService, useValue: authenticationServiceStub }, | ||||
{ provide: NavBarService, useValue: navBarServiceStub }, | { provide: NavBarService, useValue: navBarServiceStub }, | ||||
{ provide: NotificationService, useValue: notificationServiceStub }, | { provide: NotificationService, useValue: notificationServiceStub }, | ||||
{ provide: RouteService, useValue: routeServiceStub }, | { provide: RouteService, useValue: routeServiceStub }, | ||||
{ provide: ComponentFixtureAutoDetect, useValue: true } | { provide: ComponentFixtureAutoDetect, useValue: true } | ||||
], | ], | ||||
imports: [ MatCardModule, RouterModule, MatTabsModule, NgxPaginationModule, MatDialogModule, MatProgressSpinnerModule, MatSnackBarModule ], | imports: [ MatCardModule, RouterModule, MatTabsModule, NgxPaginationModule, MatDialogModule, | ||||
MatProgressSpinnerModule, MatSnackBarModule ], | |||||
}).compileComponents(); | }).compileComponents(); | ||||
fixture = TestBed.createComponent(NotificationComponent); | fixture = TestBed.createComponent(NotificationsComponent); | ||||
comp = fixture.componentInstance; | comp = fixture.componentInstance; | ||||
}); | }); | ||||
it('should set notification text', async(() => { | it('should set notification text', async(() => { | ||||
fixture.detectChanges(); | fixture.detectChanges(); | ||||
fixture.whenStable().then(() => { | fixture.whenStable().then(() => { | ||||
fixture.detectChanges(); | fixture.detectChanges(); | ||||
expect(fixture.debugElement.query(By.css('.notifications')).nativeElement.textContent).toBe('test'); | expect(fixture.debugElement.query(By.css('.notifications')).nativeElement.textContent).toBe('test'); | ||||
}); | }); | ||||
})); | })); | ||||
}); | }); |