This repository was archived by the owner on Jan 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 387
Expand file tree
/
Copy pathtable-of-contents.spec.ts
More file actions
57 lines (48 loc) · 1.48 KB
/
table-of-contents.spec.ts
File metadata and controls
57 lines (48 loc) · 1.48 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
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {Observable} from 'rxjs/Observable';
import {ActivatedRoute} from '@angular/router';
import {TableOfContents} from './table-of-contents';
import {TableOfContentsModule} from './table-of-contents.module';
import {DocsAppTestingModule} from '../../testing/testing-module';
const mockActivatedRoute = {
fragment: Observable.create(observer => {
observer.complete();
})
};
describe('TableOfContents', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [TableOfContentsModule, DocsAppTestingModule],
providers: [
{provide: ActivatedRoute, useValue: mockActivatedRoute},
]
}).compileComponents();
}));
let fixture: ComponentFixture<TableOfContents>;
let component: TableOfContents;
beforeEach(() => {
fixture = TestBed.createComponent(TableOfContents);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should have no header', () => {
const header = fixture
.nativeElement
.querySelector('h2');
expect(header).toBeNull();
});
it('should have header and links', () => {
component._links = [
{
type: 'h2',
id: 'test',
name: 'test',
top: 0,
}
];
const header = fixture.nativeElement.querySelector('h2');
expect(header).toBeDefined();
const links = fixture.nativeElement.querySelector('li');
expect(links).toBeDefined();
});
});