This repository was archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathshell.spec.ts
More file actions
72 lines (66 loc) · 2.6 KB
/
shell.spec.ts
File metadata and controls
72 lines (66 loc) · 2.6 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
63
64
65
66
67
68
69
70
71
72
import {Component} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import {AppShellModule} from './module';
import {ShellNoRender, ShellRender} from './shell';
export default function () {
describe('ShellNoRender Directive', () => {
@Component({
selector: 'test-component',
template: `<div *shellNoRender>Rendered</div>`,
})
class NoRenderTestComponent {}
it('should NOT render the element at prerender time', () => {
const fixture = TestBed
.configureTestingModule({
declarations: [NoRenderTestComponent],
imports: [AppShellModule.prerender()]
})
.createComponent(NoRenderTestComponent);
fixture.detectChanges();
expect(fixture.debugElement.childNodes.length).toBe(1);
expect(fixture.debugElement.childNodes[0].nativeNode.data).toBe('template bindings={}');
});
it('should render the element at runtime', () => {
const fixture = TestBed
.configureTestingModule({
declarations: [NoRenderTestComponent],
imports: [AppShellModule.runtime()]
})
.createComponent(NoRenderTestComponent);
fixture.detectChanges();
expect(fixture.debugElement.childNodes.length).toBe(2);
expect(fixture.debugElement.childNodes[0].nativeNode.data).toBe('template bindings={}');
expect(fixture.debugElement.childNodes[1].nativeNode.name).toBe('div');
});
});
describe('ShellRender Directive', () => {
@Component({
selector: 'test-component',
template: `<div *shellRender>Rendered</div>`,
})
class RenderTestComponent {}
it('should render the element at prerender time', () => {
const fixture = TestBed
.configureTestingModule({
declarations: [RenderTestComponent],
imports: [AppShellModule.prerender()],
})
.createComponent(RenderTestComponent);
fixture.detectChanges();
expect(fixture.debugElement.childNodes.length).toBe(2);
expect(fixture.debugElement.childNodes[0].nativeNode.data).toBe('template bindings={}');
expect(fixture.debugElement.childNodes[1].nativeNode.name).toBe('div');
});
it('should NOT render the element at runtime', () => {
const fixture = TestBed
.configureTestingModule({
declarations: [RenderTestComponent],
imports: [AppShellModule.runtime()],
})
.createComponent(RenderTestComponent);
fixture.detectChanges();
expect(fixture.debugElement.childNodes.length).toBe(1);
expect(fixture.debugElement.childNodes[0].nativeNode.data).toBe('template bindings={}');
});
});
}