From: alfonsomthd Date: Tue, 2 Oct 2018 10:08:21 +0000 (+0200) Subject: mgr/dashboard: New Landing Page: Milestone 2 X-Git-Tag: v14.0.1~108^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=af45f4778324ab78659be7d882e0650b3570e1d5;p=ceph.git mgr/dashboard: New Landing Page: Milestone 2 Added tests for InfoCard & InfoGroup components. Fixes: https://tracker.ceph.com/issues/27050 Signed-off-by: Alfonso Martínez --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/info-card/info-card.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/info-card/info-card.component.spec.ts index 70a98416d0c2..f5492508d1d3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/info-card/info-card.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/info-card/info-card.component.spec.ts @@ -17,10 +17,50 @@ describe('InfoCardComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(InfoCardComponent); component = fixture.componentInstance; - fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('Setting cardTitle makes title visible', () => { + const cardTitle = 'Card Title'; + component.cardTitle = cardTitle; + fixture.detectChanges(); + const titleDiv = fixture.debugElement.nativeElement.querySelector('.card-title'); + + expect(titleDiv.textContent).toContain(cardTitle); + }); + + it('Setting link makes anchor visible', () => { + const cardTitle = 'Card Title'; + const link = '/dashboard'; + component.cardTitle = cardTitle; + component.link = link; + fixture.detectChanges(); + const anchor = fixture.debugElement.nativeElement + .querySelector('.card-title') + .querySelector('a'); + + expect(anchor.textContent).toContain(cardTitle); + expect(anchor.href).toBe(`http://localhost${link}`); + }); + + it('Setting cardClass makes class set', () => { + const cardClass = 'my-css-card-class'; + component.cardClass = cardClass; + fixture.detectChanges(); + const card = fixture.debugElement.nativeElement.querySelector(`.card.${cardClass}`); + + expect(card).toBeTruthy(); + }); + + it('Setting contentClass makes class set', () => { + const contentClass = 'my-css-content-class'; + component.contentClass = contentClass; + fixture.detectChanges(); + const card = fixture.debugElement.nativeElement.querySelector(`.card-body.${contentClass}`); + + expect(card).toBeTruthy(); + }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/info-card/info-card.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/info-card/info-card.component.ts index 8bb7f8ed2e23..fdcbe2ecea51 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/info-card/info-card.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/info-card/info-card.component.ts @@ -13,7 +13,5 @@ export class InfoCardComponent { @Input() cardClass = ''; @Input() - imageClass: string; - @Input() contentClass: string; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/info-group/info-group.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/info-group/info-group.component.spec.ts index 22944038a616..0bb0abb5c452 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/info-group/info-group.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/info-group/info-group.component.spec.ts @@ -15,10 +15,18 @@ describe('InfoGroupComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(InfoGroupComponent); component = fixture.componentInstance; - fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('Setting groupTitle makes title visible', () => { + const groupTitle = 'Group Title'; + component.groupTitle = groupTitle; + fixture.detectChanges(); + const titleDiv = fixture.debugElement.nativeElement.querySelector('.info-group-title'); + + expect(titleDiv.textContent).toContain(groupTitle); + }); });