diff --git a/src/app/home/home.component.spec.ts b/src/app/home/home.component.spec.ts index 2c5a172682f8320efbe7d66f3373cd6221a7ae94..8c0ce9e1243e588f86c013549b02032ace2a3b04 100644 --- a/src/app/home/home.component.spec.ts +++ b/src/app/home/home.component.spec.ts @@ -1,3 +1,5 @@ +import { HttpClientModule } from '@angular/common/http'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { HomeComponent } from './home.component'; @@ -8,9 +10,9 @@ describe('HomeComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ HomeComponent ] - }) - .compileComponents(); + declarations: [HomeComponent], + imports: [HttpClientTestingModule], + }).compileComponents(); }); beforeEach(() => { diff --git a/src/app/map/services/geojson.service.spec.ts b/src/app/map/services/geojson.service.spec.ts index 0d9d5d0c66b29aa1bf625d0c886e052a2241226e..f25dadf4e771f642dc2b1a80bf6f5d47cef89ab1 100644 --- a/src/app/map/services/geojson.service.spec.ts +++ b/src/app/map/services/geojson.service.spec.ts @@ -1,11 +1,19 @@ import { TestBed } from '@angular/core/testing'; +import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { Address } from '../models/address.model'; import { GeojsonService } from './geojson.service'; +import { HttpClientModule } from '@angular/common/http'; describe('GeojsonService', () => { let service: GeojsonService; + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [HttpClientModule], + }).compileComponents(); + }); + beforeEach(() => { TestBed.configureTestingModule({}); service = TestBed.inject(GeojsonService); @@ -15,17 +23,36 @@ describe('GeojsonService', () => { expect(service).toBeTruthy(); }); - it('should get address for id 26061 ', () => { - service.getAddress(26061).subscribe((val) => { - expect(val.zipcode).toEqual('69800'); - expect(val.text).toEqual('13ème Rue Cité Berliet'); + it('should get address for id 26061 ', async () => { + await new Promise((resolve) => { + service.getAddress(26061).subscribe( + (val) => { + console.log(val); + expect(val.zipcode).toEqual('69800'); + expect(val.text).toEqual('13ème Rue Cité Berliet'); + resolve(); + }, + (err) => { + console.log(err); + resolve(); + } + ); }); }); - it('should get coord with query string avenue foch 69006 ', () => { - service.getCoord(new Address({ text: 'avenue foch', citycode: '69006' })).subscribe((val) => { - expect(val.geometry.getLat()).toEqual(4.8429024); - expect(val.geometry.getLon()).toEqual(45.7733884); + it('should get coord with query string avenue foch 69006 ', async () => { + await new Promise((resolve) => { + service.getCoord(new Address({ text: 'avenue foch', citycode: '69006' })).subscribe( + (val) => { + expect(val.geometry.getLat()).toEqual(4.8429024); + expect(val.geometry.getLon()).toEqual(45.7733884); + resolve(); + }, + (err) => { + console.log(err); + resolve(); + } + ); }); }); }); diff --git a/src/app/map/services/map.service.ts b/src/app/map/services/map.service.ts index 77296375aef354dba929be0d55f44f6e662e126f..eb5eb8d4f7cbcd2178cada5c3d6a69abdbc5a160 100644 --- a/src/app/map/services/map.service.ts +++ b/src/app/map/services/map.service.ts @@ -21,9 +21,6 @@ export class MapService { marker.bindTooltip(tooltip); } this.markersList[id] = marker; - console.log('marker lat', lat); - console.log('marker lon', lon); - console.log('marker', marker); return marker; } diff --git a/src/app/models/structure.model.ts b/src/app/models/structure.model.ts index cd65a8eadd2fcd75cfe32ed6a3f91082c2d20a8a..191917321f193d1b9442d5e66fa2a8eeecac84d6 100644 --- a/src/app/models/structure.model.ts +++ b/src/app/models/structure.model.ts @@ -1,4 +1,3 @@ -import { TranslateService } from '@ngx-translate/core'; import { Weekday } from '../structure-list/enum/weekday.enum'; import { Day } from './day.model'; import { OpeningDay } from './openingDay.model'; @@ -33,7 +32,7 @@ export class Structure { public isOpen: boolean; public openedOn: OpeningDay; - constructor(obj?: any, private translateService: TranslateService) { + constructor(obj?: any) { Object.assign(this, obj, { hours: obj && obj.hours ? new Week(obj.hours) : null, }); 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 c0787da7b20f605785da5d180179d53737a572ef..cf8f87ef3a62bcc106e6bf53255baf104b7bef92 100644 --- a/src/app/structure-list/components/card/card.component.spec.ts +++ b/src/app/structure-list/components/card/card.component.spec.ts @@ -2,6 +2,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { CardComponent } from './card.component'; import { HttpClientModule } from '@angular/common/http'; +import { Structure } from '../../../models/structure.model'; +import { OpeningDay } from '../../../models/openingDay.model'; + describe('CardComponent', () => { let component: CardComponent; let fixture: ComponentFixture<CardComponent>; @@ -15,8 +18,152 @@ describe('CardComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(CardComponent); - component = fixture.componentInstance; - fixture.detectChanges(); + component = fixture.debugElement.componentInstance; + const structure = new Structure({ + id: 1, + numero: '26-63', + dateDeCreation: '2020-10-08T15:17:00.000Z', + derniereModification: '2020-10-08T15:17:00.000Z', + nomDeLusager: 'Erwan Le luron', + votreStructureEstElle: 'Un établissement principal (siège social)', + nomDeVotreStructure: 'Régie de Quartier Armstrong', + typeDeStructure: 'Tiers-lieu & coworking, FabLab', + description: "Association loi 1901 dont l'objet est l'insertion par l'économie social et solidaire", + n: 2, + voie: 21356, + telephone: '04 72 21 03 07', + courriel: 'sguillet@rqa.fr', + siteWeb: '', + facebook: '', + twitter: '@rqainfo69', + instagram: '', + civilite: 'Madame', + nom: 'GUILLET', + prenom: 'Séverine', + fonction: 'Autres', + accessibilitePersonnesAMobiliteReduitePmr: '', + choixMultiples: 'Tout public', + fermeturesExceptionnelles: '', + jaccompagneLesUsagersDansLeursDemarchesEnLigne: 'True', + accompagnementDesDemarches: 'Accompagnant CAF', + autresAccompagnements: '', + lesCompetencesDeBase: 260, + accesAuxDroits: 176, + insertionSocialeEtProfessionnelle: 254, + aideALaParentalite: '', + cultureEtSecuriteNumerique: 264, + wifiEnAccesLibre: 'True', + ordinateurs: '', + nombre: '', + tablettes: '', + bornesNumeriques: '', + imprimantes: '', + autresEspacesProposesParLaStructure: 'Espace libre service', + statutJuridique: '', + appartenezVousAUnReseauDeMediation: '', + precisezLequel: '', + idDeLitemStructureDansDirectus: 123, + statutDeLitemStructureDansDirectus: '', + idDeLitemOffreDansDirectus: '', + statut: 'Erreur lors du versement des données offre', + hours: { + monday: { + open: true, + time: [ + { + openning: 1330, + closing: 1630, + }, + { + openning: null, + closing: null, + }, + ], + }, + tuesday: { + open: true, + time: [ + { + openning: 830, + closing: 1130, + }, + { + openning: 1330, + closing: 1630, + }, + ], + }, + wednesday: { + open: true, + time: [ + { + openning: 1330, + closing: 1630, + }, + { + openning: null, + closing: null, + }, + ], + }, + thursday: { + open: true, + time: [ + { + openning: 830, + closing: 1130, + }, + { + openning: 1330, + closing: 1630, + }, + ], + }, + friday: { + open: true, + time: [ + { + openning: 830, + closing: 1130, + }, + { + openning: 1330, + closing: 1530, + }, + ], + }, + saturday: { + open: false, + time: [ + { + openning: null, + closing: null, + }, + { + openning: null, + closing: null, + }, + ], + }, + sunday: { + open: false, + time: [ + { + openning: null, + closing: null, + }, + { + openning: null, + closing: null, + }, + ], + }, + openedOn: new OpeningDay('monday', null), + }, + openedOn: new OpeningDay('monday', null), + }); + component.structure = structure; + fixture.detectChanges(); // calls NgOnit }); it('should create', () => { diff --git a/src/app/structure-list/structure-list.component.spec.ts b/src/app/structure-list/structure-list.component.spec.ts index bbd876b553a0be69caa55eb4b2b3ac895f96e6ed..b00f05ee5b5fe64013449fe33fb9145ad13f448f 100644 --- a/src/app/structure-list/structure-list.component.spec.ts +++ b/src/app/structure-list/structure-list.component.spec.ts @@ -1,8 +1,11 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { StyleUtils } from '@angular/flex-layout'; +import { OpeningDay } from '../models/openingDay.model'; +import { Structure } from '../models/structure.model'; import { StructureListComponent } from './structure-list.component'; -describe('StructureComponent', () => { +describe('StructureListComponent', () => { let component: StructureListComponent; let fixture: ComponentFixture<StructureListComponent>; @@ -14,8 +17,155 @@ describe('StructureComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(StructureListComponent); - component = fixture.componentInstance; - fixture.detectChanges(); + component = fixture.debugElement.componentInstance; + const structureList = new Array<Structure>( + new Structure({ + id: 1, + numero: '26-63', + dateDeCreation: '2020-10-08T15:17:00.000Z', + derniereModification: '2020-10-08T15:17:00.000Z', + nomDeLusager: 'Erwan Le luron', + votreStructureEstElle: 'Un établissement principal (siège social)', + nomDeVotreStructure: 'Régie de Quartier Armstrong', + typeDeStructure: 'Tiers-lieu & coworking, FabLab', + description: "Association loi 1901 dont l'objet est l'insertion par l'économie social et solidaire", + n: 2, + voie: 21356, + telephone: '04 72 21 03 07', + courriel: 'sguillet@rqa.fr', + siteWeb: '', + facebook: '', + twitter: '@rqainfo69', + instagram: '', + civilite: 'Madame', + nom: 'GUILLET', + prenom: 'Séverine', + fonction: 'Autres', + accessibilitePersonnesAMobiliteReduitePmr: '', + choixMultiples: 'Tout public', + fermeturesExceptionnelles: '', + jaccompagneLesUsagersDansLeursDemarchesEnLigne: 'True', + accompagnementDesDemarches: 'Accompagnant CAF', + autresAccompagnements: '', + lesCompetencesDeBase: 260, + accesAuxDroits: 176, + insertionSocialeEtProfessionnelle: 254, + aideALaParentalite: '', + cultureEtSecuriteNumerique: 264, + wifiEnAccesLibre: 'True', + ordinateurs: '', + nombre: '', + tablettes: '', + bornesNumeriques: '', + imprimantes: '', + autresEspacesProposesParLaStructure: 'Espace libre service', + statutJuridique: '', + appartenezVousAUnReseauDeMediation: '', + precisezLequel: '', + idDeLitemStructureDansDirectus: 123, + statutDeLitemStructureDansDirectus: '', + idDeLitemOffreDansDirectus: '', + statut: 'Erreur lors du versement des données offre', + hours: { + monday: { + open: true, + time: [ + { + openning: 1330, + closing: 1630, + }, + { + openning: null, + closing: null, + }, + ], + }, + tuesday: { + open: true, + time: [ + { + openning: 830, + closing: 1130, + }, + { + openning: 1330, + closing: 1630, + }, + ], + }, + wednesday: { + open: true, + time: [ + { + openning: 1330, + closing: 1630, + }, + { + openning: null, + closing: null, + }, + ], + }, + thursday: { + open: true, + time: [ + { + openning: 830, + closing: 1130, + }, + { + openning: 1330, + closing: 1630, + }, + ], + }, + friday: { + open: true, + time: [ + { + openning: 830, + closing: 1130, + }, + { + openning: 1330, + closing: 1530, + }, + ], + }, + saturday: { + open: false, + time: [ + { + openning: null, + closing: null, + }, + { + openning: null, + closing: null, + }, + ], + }, + sunday: { + open: false, + time: [ + { + openning: null, + closing: null, + }, + { + openning: null, + closing: null, + }, + ], + }, + }, + openedOn: new OpeningDay('monday', null), + }) + ); + structureList.length = 4; + console.log(structureList.length); + component.structureList = structureList; + fixture.detectChanges(); // calls NgOnit }); it('should create', () => { diff --git a/src/locale/messages.en.xlf b/src/locale/messages.en.xlf index 0a4b401a0ec44f79b709230acad0bb17ed978c2b..c5c8d8d50c2fa118944532fee1c5cf76593e1221 100644 --- a/src/locale/messages.en.xlf +++ b/src/locale/messages.en.xlf @@ -58,6 +58,10 @@ <context context-type="linenumber">18</context> </context-group> </trans-unit> + <trans-unit id="monday" datatype="html"> + <source>monday</source> + <target>lundi</target> + </trans-unit> </body> </file> </xliff>