From 1c91bf5979ff0d3e25c3ea4ddf024d3302893d4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Poupard?= Date: Wed, 12 Feb 2020 16:54:56 +0100 Subject: [PATCH] fix(tests): adjust assertions --- .../lib/o-navbar/o-navbar.component.spec.ts | 9 ++-- .../src/lib/o-switch/switch.component.spec.ts | 8 +-- src/app/app.component.spec.ts | 5 +- .../boostwatch/boostwatch.component.spec.ts | 52 +++++++++++++++++-- src/app/demos/o-navbar.component.html | 2 +- src/app/start/start.component.spec.ts | 4 +- 6 files changed, 60 insertions(+), 20 deletions(-) diff --git a/projects/ng-boosted/src/lib/o-navbar/o-navbar.component.spec.ts b/projects/ng-boosted/src/lib/o-navbar/o-navbar.component.spec.ts index 54992196..80558b1d 100644 --- a/projects/ng-boosted/src/lib/o-navbar/o-navbar.component.spec.ts +++ b/projects/ng-boosted/src/lib/o-navbar/o-navbar.component.spec.ts @@ -46,21 +46,21 @@ describe('ONavbarComponent', () => { expect(component.isCollapsed).toBeTruthy(); }); - it('The value of title of the img tag html attribute should be brand label', () => { + it('The .navbar-brand link title should be brand label', () => { component.brandLabel = 'brand label'; fixture.detectChanges(); const ataghtml: HTMLElement = fixture.debugElement.nativeElement; - expect(ataghtml.querySelector('img').getAttribute('title')).toEqual('brand label'); + expect(ataghtml.querySelector('a.logo').getAttribute('title')).toEqual('brand label'); }); - it('The value of source of the img tag html attribute should be src img', () => { + it('The .navbar-brand img source should be src/img', () => { component.brandPath = '/src/img/'; fixture.detectChanges(); const ataghtml: HTMLElement = fixture.debugElement.nativeElement; expect(ataghtml.querySelector('img').getAttribute('src')).toEqual('/src/img/'); }); - it('Get RouterLinks from tempalte and check if it is equal to home', () => { + it('Get RouterLinks from template and check if it equals home', () => { component.homeRoute = '/home'; fixture.detectChanges(); expect(routerLinks[0].linkParams).toBe('/home'); @@ -81,7 +81,6 @@ describe('ONavbarComponent', () => { it('Check the click event on button', () => { component.homeRoute = '/home'; fixture.detectChanges(); - const ataghtml: HTMLElement = fixture.debugElement.nativeElement; testButton.triggerEventHandler('click', null); expect(component.isCollapsed).toBeFalsy(); }); diff --git a/projects/ng-boosted/src/lib/o-switch/switch.component.spec.ts b/projects/ng-boosted/src/lib/o-switch/switch.component.spec.ts index 8553e55c..c814713c 100644 --- a/projects/ng-boosted/src/lib/o-switch/switch.component.spec.ts +++ b/projects/ng-boosted/src/lib/o-switch/switch.component.spec.ts @@ -31,17 +31,17 @@ describe('OSwitchComponent', () => { it('The value of toggled should be false', () => { expect(component.toggled).toBeFalsy(); }); - - it('The value of id and the name of the input tag html attribute should be Input#1', () => { + + it('The id name of the input tag should be Input#1', () => { component.inputId = 'Input#1'; fixture.detectChanges(); const inputTagHtml: HTMLElement = fixture.debugElement.nativeElement; expect(inputTagHtml.querySelector('input').getAttribute('id')).toEqual('Input#1'); }); - it('Simulated a click on the input with subscriotion to the output', () => { + it('Simulate a click on the input with subscription to the output', () => { component.toggled = true; - component.inputId = 'Input#2'; + component.inputId = 'Input#1'; input.triggerEventHandler('click', null); fixture.detectChanges(); diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index f32eb113..3230a6a1 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -19,13 +19,12 @@ describe('AppComponent', () => { expect(app).toBeTruthy(); }); - it(`should have as footer with "Designed and built by the Boosted team"`, () => { + it(`should have a footer with "Designed and built by the Boosted team"`, () => { const fixture = TestBed.createComponent(AppComponent); const bannerDe: DebugElement = fixture.debugElement; - const paragraphDe = bannerDe.query(By.css('.o-footer-top')); + const paragraphDe = bannerDe.query(By.css('.o-footer-body p:first-child')); const p: HTMLElement = paragraphDe.nativeElement; fixture.detectChanges(); - const app = fixture.debugElement.componentInstance; expect(p.textContent).toEqual('Designed and built by the Boosted team.'); }); }); diff --git a/src/app/boostwatch/boostwatch.component.spec.ts b/src/app/boostwatch/boostwatch.component.spec.ts index 7b07a3f0..d64cb497 100644 --- a/src/app/boostwatch/boostwatch.component.spec.ts +++ b/src/app/boostwatch/boostwatch.component.spec.ts @@ -18,9 +18,19 @@ import { DemoOSwitch } from '../demos/o-switch.component'; import { DemoOToggle } from '../demos/o-toggle.component'; import { DemoSwiper } from '../demos/swiper.component'; import { DemoONavbar } from '../demos/o-navbar.component'; +import { HomeComponent } from '../home/home.component'; import { BoostwatchComponent } from './boostwatch.component'; import { DemoToast } from '../demos/toast.component'; -import { OCalendarModule, OSwitchModule, OCarouselModule } from 'ng-boosted'; +import { + OCalendarModule, + OSwitchModule, + OCarouselModule, + ONavbarModule, + ODropdownModule, + ONavLinkModule, ONavMenuModule, ScrollTopModule, OToastModule +} from 'ng-boosted'; +import {RouterTestingModule} from "@angular/router/testing"; +import {AppRoutingModule} from "../app-routing.module"; describe('BoostwatchComponent', () => { let component: BoostwatchComponent; @@ -28,10 +38,42 @@ describe('BoostwatchComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - imports: [ NgbModule, BrowserModule, FormsModule, OCalendarModule, OSwitchModule, OCarouselModule ], - declarations: [ BoostwatchComponent, DemoAccordion, DemoModal, DemoTabs, DemoPagination, DemoTooltip, - DemoPopover, DemoAlert, DemoCarousel, DemoOCalendar, DemoCollapse, DemoProgressBar, DemoDropdown, - DemoOSwitch, DemoOToggle, DemoSwiper, DemoONavbar, DemoToast ] + imports: [ + BrowserModule, + FormsModule, + NgbModule, + AppRoutingModule, + OCalendarModule, + OCarouselModule, + ODropdownModule, + ONavLinkModule, + ONavMenuModule, + ONavbarModule, + ScrollTopModule, + OSwitchModule, + OToastModule + ], + declarations: [ + BoostwatchComponent, + HomeComponent, + DemoAccordion, + DemoModal, + DemoTabs, + DemoPagination, + DemoTooltip, + DemoPopover, + DemoAlert, + DemoCarousel, + DemoOCalendar, + DemoCollapse, + DemoProgressBar, + DemoDropdown, + DemoOSwitch, + DemoOToggle, + DemoSwiper, + DemoONavbar, + DemoToast + ] }) .compileComponents(); })); diff --git a/src/app/demos/o-navbar.component.html b/src/app/demos/o-navbar.component.html index fb19d797..0d808fd0 100644 --- a/src/app/demos/o-navbar.component.html +++ b/src/app/demos/o-navbar.component.html @@ -1,5 +1,5 @@ -
  • Getting started
  • +
  • Getting started
  • basket diff --git a/src/app/start/start.component.spec.ts b/src/app/start/start.component.spec.ts index 2eace1e1..fc8c685f 100644 --- a/src/app/start/start.component.spec.ts +++ b/src/app/start/start.component.spec.ts @@ -23,9 +23,9 @@ describe('StartComponent', () => { expect(component).toBeTruthy(); }); - it('should have

    with "Dependencies"', () => { + it('should have

    with "Dependencies"', () => { const bannerElement: HTMLElement = fixture.nativeElement; - const p = bannerElement.querySelector('h3'); + const p = bannerElement.querySelector('h2'); expect(p.textContent).toEqual('Dependencies'); }); });