diff --git a/src/app/structure-list/components/card/card.component.spec.ts b/src/app/structure-list/components/card/card.component.spec.ts index cf8f87ef3a62bcc106e6bf53255baf104b7bef92..f3a5672df70b951fd57c4d9737575c09b0d54834 100644 --- a/src/app/structure-list/components/card/card.component.spec.ts +++ b/src/app/structure-list/components/card/card.component.spec.ts @@ -8,7 +8,7 @@ import { OpeningDay } from '../../../models/openingDay.model'; describe('CardComponent', () => { let component: CardComponent; let fixture: ComponentFixture<CardComponent>; - + let structure: Structure; beforeEach(async () => { await TestBed.configureTestingModule({ imports: [HttpClientModule], @@ -19,7 +19,7 @@ describe('CardComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(CardComponent); component = fixture.debugElement.componentInstance; - const structure = new Structure({ + structure = new Structure({ id: 1, numero: '26-63', dateDeCreation: '2020-10-08T15:17:00.000Z', @@ -169,4 +169,28 @@ describe('CardComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('should transform a distance into km', () => { + component.structure.distance = 4320; + const distance = component.formatDistance(); + expect(distance).toEqual('4.3 km'); + }); + it('should transform a distance into m', () => { + component.structure.distance = 400; + const distance = component.formatDistance(); + expect(distance).toEqual('400 m'); + }); + + it('should emit structure to show details', () => { + spyOn(component.showDetails, 'emit'); + component.cardClicked(); + expect(component.showDetails.emit).toHaveBeenCalled(); + expect(component.showDetails.emit).toHaveBeenCalledWith(structure); + }); + it('should emit structure on cardHover', () => { + spyOn(component.hover, 'emit'); + component.cardHover(); + expect(component.hover.emit).toHaveBeenCalled(); + expect(component.hover.emit).toHaveBeenCalledWith(structure); + }); }); diff --git a/src/app/structure-list/components/card/card.component.ts b/src/app/structure-list/components/card/card.component.ts index 4050fe75977be0d50656f01a435fc478ffb41f4a..faa643618883bbab38d6cf1dc735ea270d3e5401 100644 --- a/src/app/structure-list/components/card/card.component.ts +++ b/src/app/structure-list/components/card/card.component.ts @@ -38,6 +38,7 @@ export class CardComponent implements OnInit { } public cardClicked(): void { + console.log(this.structure); this.showDetails.emit(this.structure); }