-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathheader-account-menu.component.spec.ts
More file actions
60 lines (55 loc) · 1.97 KB
/
Copy pathheader-account-menu.component.spec.ts
File metadata and controls
60 lines (55 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { Config } from '../../../domain/config';
import { ConfigService } from '../../../services/config.service';
import { HeaderAccountMenuComponent } from './header-account-menu.component';
import { MatMenuModule } from '@angular/material/menu';
import { Observable } from 'rxjs';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { provideRouter } from '@angular/router';
import { User } from '../../../domain/user';
import { LogOutService } from '../../../services/logOutService';
export class MockConfigService {
getConfig(): Observable<Config> {
const config: Config = {
contextPath: '/wise',
logOutURL: '/logout',
currentTime: new Date('2018-10-17T00:00:00.0').getTime()
};
return Observable.create((observer) => {
observer.next(config);
observer.complete();
});
}
}
describe('HeaderAccountMenuComponent', () => {
let component: HeaderAccountMenuComponent;
let fixture: ComponentFixture<HeaderAccountMenuComponent>;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [HeaderAccountMenuComponent, MatMenuModule],
providers: [
LogOutService,
{ provide: ConfigService, useClass: MockConfigService },
provideRouter([]),
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting()
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(HeaderAccountMenuComponent);
component = fixture.componentInstance;
const user: User = new User();
user.id = 1;
user.firstName = 'Amanda';
user.lastName = 'Panda';
user.roles = ['student'];
user.username = 'AmandaP0101';
component.user = user;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});