-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(fix-297): Get the 'presence_joint' information from fiche_techniq…
…ue if unknown
- Loading branch information
Jérôme GAVIGNET
committed
Jan 7, 2025
1 parent
8fee1db
commit d911b6e
Showing
9 changed files
with
1,813 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
import getFicheTechnique from './ficheTechnique.js'; | ||
|
||
describe('FicheTechnique service tests', () => { | ||
const dpe = { | ||
fiche_technique_collection: { | ||
fiche_technique: [ | ||
{ | ||
enum_categorie_fiche_technique_id: '10', | ||
sous_fiche_technique_collection: { | ||
sous_fiche_technique: [ | ||
{ | ||
description: 'Type de ventilation: VMC SF Auto réglable avant 1982', | ||
valeur: 'VMC SF Auto réglable avant 1982', | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '2' | ||
}, | ||
{ | ||
description: 'Année installation: 1949', | ||
valeur: 1949, | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '1' | ||
}, | ||
{ | ||
description: 'Energie utilisée: Electrique', | ||
valeur: 'Electrique', | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '2' | ||
}, | ||
{ | ||
description: 'Façades exposées: plusieurs', | ||
valeur: 'plusieurs', | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '2' | ||
}, | ||
{ | ||
description: 'Logement Traversant: oui', | ||
valeur: 'oui', | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '2' | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
enum_categorie_fiche_technique_id: '10', | ||
sous_fiche_technique_collection: { | ||
sous_fiche_technique: [ | ||
{ | ||
description: 'Type de ventilation: VMC SF Auto réglable avant 1982', | ||
valeur: 'VMC SF Auto réglable avant 1982', | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '2' | ||
}, | ||
{ | ||
description: 'Année installation: 1950', | ||
valeur: 1950, | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '1' | ||
}, | ||
{ | ||
description: 'Energie utilisée: Bois', | ||
valeur: 'Bois', | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '2' | ||
}, | ||
{ | ||
description: 'Façades exposées: plusieurs', | ||
valeur: 'plusieurs', | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '2' | ||
}, | ||
{ | ||
description: 'Logement Traversant: oui', | ||
valeur: 'oui', | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '2' | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
enum_categorie_fiche_technique_id: '10', | ||
sous_fiche_technique_collection: { | ||
sous_fiche_technique: [ | ||
{ | ||
description: 'Type de ventilation: VMC SF Auto réglable avant 1982', | ||
valeur: 'VMC SF Auto réglable avant 1982', | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '2' | ||
}, | ||
{ | ||
description: 'Année installation: 1950', | ||
valeur: 1950, | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '1' | ||
}, | ||
{ | ||
description: 'Energie utilisée: Gaz', | ||
valeur: 'Gaz', | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '2' | ||
}, | ||
{ | ||
description: 'Façades exposées: plusieurs', | ||
valeur: 'aucune', | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '2' | ||
}, | ||
{ | ||
description: 'Logement Traversant: oui', | ||
valeur: 'oui', | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '2' | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
}; | ||
|
||
it('should return a fiche technique', async () => { | ||
let fiche = getFicheTechnique(dpe, '10', 'exposées'); | ||
expect(fiche).not.toBeNull(); | ||
expect(fiche.description).toBe('Façades exposées: plusieurs'); | ||
expect(fiche.valeur).toBe('plusieurs'); | ||
|
||
// Some DPE have a fiche_technique node which is not an array | ||
const dpeWithoutArray = { | ||
fiche_technique_collection: { | ||
fiche_technique: { | ||
enum_categorie_fiche_technique_id: '10', | ||
sous_fiche_technique_collection: { | ||
sous_fiche_technique: [ | ||
{ | ||
description: 'Façades exposées: plusieurs', | ||
valeur: 'plusieurs', | ||
detail_origine_donnee: '', | ||
enum_origine_donnee_id: '2' | ||
} | ||
] | ||
} | ||
} | ||
} | ||
}; | ||
|
||
fiche = getFicheTechnique(dpeWithoutArray, '10', 'exposées'); | ||
expect(fiche).not.toBeNull(); | ||
}); | ||
|
||
it('should return a fiche technique with multiple criteria', async () => { | ||
let fiche = getFicheTechnique(dpe, '10', 'exposées', [1950, 'Gaz']); | ||
expect(fiche).not.toBeNull(); | ||
expect(fiche.description).toBe('Façades exposées: plusieurs'); | ||
expect(fiche.valeur).toBe('aucune'); | ||
}); | ||
|
||
it('should not return a non existing fiche technique', async () => { | ||
let fiche = getFicheTechnique(dpe, '40', 'exposées'); | ||
expect(fiche).toBeNull(); | ||
|
||
fiche = getFicheTechnique(dpe, '10', 'non existing'); | ||
expect(fiche).toBeNull(); | ||
|
||
dpe.fiche_technique_collection.fiche_technique[0].sous_fiche_technique_collection.sous_fiche_technique = | ||
null; | ||
|
||
fiche = getFicheTechnique(dpe, '11', 'non existing'); | ||
expect(fiche).toBeNull(); | ||
|
||
dpe.fiche_technique_collection.fiche_technique[0].sous_fiche_technique_collection = null; | ||
|
||
fiche = getFicheTechnique(dpe, '11', 'non existing'); | ||
expect(fiche).toBeNull(); | ||
|
||
dpe.fiche_technique_collection.fiche_technique = null; | ||
|
||
fiche = getFicheTechnique(dpe, '10', 'non existing'); | ||
expect(fiche).toBeNull(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,5 +191,6 @@ | |
"2459E0028946S", | ||
"2395E2435060X", | ||
"2438E4094489Y", | ||
"2159E1018555M" | ||
"2159E1018555M", | ||
"2269E1217015Z" | ||
] |
Oops, something went wrong.