forked from angular/angular
/
api-pages.e2e-spec.ts
86 lines (71 loc) · 3.6 KB
/
api-pages.e2e-spec.ts
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import {ApiPage} from './api.po';
describe('Api pages', () => {
let page: ApiPage;
beforeEach(() => page = new ApiPage());
it('should show direct subclasses of a class', async () => {
await page.navigateTo('api/forms/AbstractControlDirective');
expect(await page.getDescendants('class', true)).toEqual(['ControlContainer', 'NgControl']);
});
it('should show direct and indirect subclasses of a class', async () => {
await page.navigateTo('api/forms/AbstractControlDirective');
expect(await page.getDescendants('class')).toEqual([
'ControlContainer', 'AbstractFormGroupDirective', 'NgModelGroup', 'FormGroupName', 'NgForm',
'FormGroupDirective', 'FormArrayName', 'NgControl', 'NgModel', 'FormControlDirective',
'FormControlName'
]);
});
it('should show child interfaces that extend an interface', async () => {
await page.navigateTo('api/forms/Validator');
expect(await page.getDescendants('interface')).toEqual(['AsyncValidator']);
});
it('should show classes that implement an interface', async () => {
await page.navigateTo('api/animations/AnimationPlayer');
expect(await page.getDescendants('class')).toEqual([
'NoopAnimationPlayer', 'MockAnimationPlayer'
]);
});
it('should show type params of type-aliases', async () => {
await page.navigateTo('api/common/http/HttpEvent');
expect(await page.getOverview('type-alias').getText()).toContain('type HttpEvent<T>');
});
it('should not show parenthesis for getters', async () => {
await page.navigateTo('api/core/NgModuleRef');
expect(await page.getOverview('class').getText()).toContain('injector: EnvironmentInjector');
});
it('should show both type and initializer if set', async () => {
await page.navigateTo('api/common/HashLocationStrategy');
expect(await page.getOverview('class').getText())
.toContain('path(includeHash: boolean = false): string');
});
it('should show a "Properties" section if there are public properties', async () => {
await page.navigateTo('api/core/ViewContainerRef');
expect(await page.getSection('instance-properties').isPresent()).toBe(true);
});
it('should not show a "Properties" section if there are only internal properties', async () => {
await page.navigateTo('api/forms/AsyncValidator');
expect(await page.getSection('instance-properties').isPresent()).toBe(false);
});
it('should show "impure" badge if pipe is not pure', async () => {
await page.navigateTo('api/common/AsyncPipe');
expect(await page.getBadge('impure-pipe').isPresent()).toBe(true);
});
it('should show links to github', async () => {
await page.navigateTo('api/core/EventEmitter');
/* eslint-disable max-len */
expect(await page.ghLinks.get(0).getAttribute('href'))
.toMatch(
/https:\/\/github\.com\/angular\/angular\/edit\/main\/packages\/core\/src\/event_emitter\.ts\?message=docs\(core\)%3A%20describe%20your%20change\.\.\.#L\d+-L\d+/);
expect(await page.ghLinks.get(1).getAttribute('href'))
.toMatch(
/https:\/\/github\.com\/angular\/angular\/tree\/[^/]+\/packages\/core\/src\/event_emitter\.ts#L\d+-L\d+/);
/* eslint-enable max-len */
});
it('should show all overloads of interface methods', async () => {
await page.navigateTo('api/core/testing/TestBed');
expect(await (await page.getInstanceMethodOverloads('inject')).length).toEqual(4);
});
it('should show all overloads of pseudo-class methods', async () => {
await page.navigateTo('api/core/testing/TestBed');
expect(await (await page.getInstanceMethodOverloads('inject')).length).toEqual(4);
});
});