Skip to content

Commit ab7e49f

Browse files
amcdnljosephperrott
authored andcommitted
chore(test): add test for lazy loaded
1 parent 51d7742 commit ab7e49f

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/lib/tabs/tab-group.spec.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,34 @@ describe('nested MdTabGroup with enabled animations', () => {
405405
});
406406

407407

408+
describe('lazy loaded tabs', () => {
409+
beforeEach(async(() => {
410+
TestBed.configureTestingModule({
411+
imports: [MdTabsModule, BrowserAnimationsModule],
412+
declarations: [TemplateTabs]
413+
});
414+
415+
TestBed.compileComponents();
416+
}));
417+
418+
it('should lazy load the second tab', (done) => {
419+
let fixture = TestBed.createComponent(TemplateTabs);
420+
fixture.detectChanges();
421+
422+
let tabLabel = fixture.debugElement.queryAll(By.css('.mat-tab-label'))[1];
423+
tabLabel.nativeElement.click();
424+
fixture.detectChanges();
425+
426+
fixture.whenStable().then(() => {
427+
fixture.detectChanges();
428+
let child = fixture.debugElement.query(By.css('.child'));
429+
expect(child.nativeElement).toBeDefined();
430+
done();
431+
});
432+
});
433+
});
434+
435+
408436
@Component({
409437
template: `
410438
<md-tab-group class="tab-group"
@@ -583,3 +611,20 @@ class TabGroupWithSimpleApi {
583611
})
584612
class NestedTabs {}
585613

614+
615+
@Component({
616+
selector: 'template-tabs',
617+
template: `
618+
<md-tab-group>
619+
<md-tab label="One">
620+
Eager
621+
</md-tab>
622+
<md-tab label="Two">
623+
<ng-template mdTabContent>
624+
<div class="child">Hi</div>
625+
</ng-template>
626+
</md-tab>
627+
</md-tab-group>
628+
`,
629+
})
630+
class TemplateTabs {}

0 commit comments

Comments
 (0)