Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

Commit

Permalink
fix(tests): adjust assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
ffoodd committed Feb 12, 2020
1 parent a2ee8a3 commit 1c91bf5
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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();
});
Expand Down
8 changes: 4 additions & 4 deletions projects/ng-boosted/src/lib/o-switch/switch.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
});
});
52 changes: 47 additions & 5 deletions src/app/boostwatch/boostwatch.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,62 @@ 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;
let fixture: ComponentFixture<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();
}));
Expand Down
2 changes: 1 addition & 1 deletion src/app/demos/o-navbar.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<lib-o-navbar homeRoute="/start" breakpoint="sm" containerClass="container-fluid" brandPath="assets/img/orange_logo.svg" brandLabel="Back to home page" isCollapsed={{isCollapsed}}>
<li o-nav-link route="/documentation" [query]="{id: 'my_id'}" (click)="isCollapsed = !isCollapsed">Getting started</li>
<li o-nav-link route="/documentation" query="{id: 'my_id'}" (click)="isCollapsed = !isCollapsed">Getting started</li>

<li o-nav-link route="/start" title="Shop">
<span class="sr-only">basket</span>
Expand Down
4 changes: 2 additions & 2 deletions src/app/start/start.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ describe('StartComponent', () => {
expect(component).toBeTruthy();
});

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

0 comments on commit 1c91bf5

Please sign in to comment.