-
-
Notifications
You must be signed in to change notification settings - Fork 350
Expand file tree
/
Copy pathapp.component.spec.ts
More file actions
62 lines (55 loc) · 1.87 KB
/
app.component.spec.ts
File metadata and controls
62 lines (55 loc) · 1.87 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
61
62
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatIconModule } from '@angular/material/icon';
import { MatSidenavModule } from '@angular/material/sidenav';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { of } from 'rxjs';
import { ThemeService } from './service/theme.service';
import { TitleService } from './service/title.service';
class MockThemeService {
initTheme() {}
}
class MockTitleService {
titleInfo$ = of({
dimension: 'Test Title',
level: '1',
});
}
describe('AppComponent', () => {
let app: AppComponent;
let fixture: ComponentFixture<AppComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [AppComponent],
imports: [
RouterTestingModule,
MatToolbarModule,
MatIconModule,
MatSidenavModule,
BrowserAnimationsModule,
],
providers: [
{ provide: ThemeService, useClass: MockThemeService },
{ provide: TitleService, useClass: MockTitleService },
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
}).compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AppComponent);
app = fixture.componentInstance;
fixture.detectChanges();
});
it('should create the app', () => {
expect(app).toBeTruthy();
});
it('check for fork me on github ribbon generation', () => {
const compiled = fixture.nativeElement as HTMLElement;
const githubLink = compiled.querySelector('.github-fork-ribbon');
expect(githubLink).not.toBeNull();
expect(githubLink?.textContent?.trim()).toBe('Fork me on GitHub');
});
});