Skip to content

Commit

Permalink
writing unit tests for the html structure
Browse files Browse the repository at this point in the history
fixes for #30
  • Loading branch information
Muhammad Hasan committed Sep 19, 2019
1 parent eb9219b commit e05e5da
Showing 1 changed file with 44 additions and 3 deletions.
47 changes: 44 additions & 3 deletions src/app/landing/landing.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { LandingComponent } from './landing.component';
import { CUSTOM_ELEMENTS_SCHEMA, ChangeDetectorRef } from '@angular/core';
import { CUSTOM_ELEMENTS_SCHEMA, ChangeDetectorRef, DebugElement } from '@angular/core';
import { UserService } from '../services/user.service';
import { MediaMatcher } from '@angular/cdk/layout';

Expand All @@ -24,7 +24,48 @@ describe('LandingComponent', () => {
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
it('should contain landing toolbar component ', () => {
const nativeEl: HTMLElement = fixture.debugElement.nativeElement;
const toolbarComp = nativeEl.querySelector('dahab-landing-toolbar');
expect(toolbarComp).toBeTruthy();
});

it('should have matSidenavContainer component ', () => {
const nativeEl: HTMLElement = fixture.debugElement.nativeElement;
const comp = nativeEl.querySelector('mat-sidenav-container');
expect(comp).toBeTruthy();
});

it('matSidenavContainer should contain matSidenav ', () => {
const nativeEl: HTMLElement = fixture.debugElement.nativeElement;
const comp = nativeEl.querySelector('mat-sidenav-container').querySelector('mat-sidenav');
expect(comp).toBeTruthy();
});


it('matSidenavContainer should contain matSidenavContent', () => {
const nativeEl: HTMLElement = fixture.debugElement.nativeElement;
const comp = nativeEl.querySelector('mat-sidenav-container').querySelector('mat-sidenav-content');
expect(comp).toBeTruthy();
});



it('matSidenavContent should contain a routerOutlet', () => {
const nativeEl: HTMLElement = fixture.debugElement.nativeElement;
const comp = nativeEl.querySelector('mat-sidenav-content').querySelector('router-outlet');
expect(comp).toBeTruthy();
});




it('should contain h2 tag with the value \'stay tuned\'', () => {
const debugEl: DebugElement = fixture.debugElement;
const nativeEl: HTMLElement = fixture.debugElement.nativeElement;
const h2 = nativeEl.querySelector('h2');
expect(h2.textContent).toEqual('Stay tuned...');
});


});

0 comments on commit e05e5da

Please sign in to comment.