Skip to content
Snippets Groups Projects
Commit e8837b4f authored by Jérémie BRISON's avatar Jérémie BRISON
Browse files

fix(card) : set Unit test

parent 32d756e2
No related branches found
No related tags found
2 merge requests!31Recette,!19Test dev
......@@ -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);
});
});
......@@ -38,6 +38,7 @@ export class CardComponent implements OnInit {
}
public cardClicked(): void {
console.log(this.structure);
this.showDetails.emit(this.structure);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment