-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathopen3cl-sorties-ep-conso.spec.js
73 lines (68 loc) · 2.55 KB
/
open3cl-sorties-ep-conso.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { calcul_3cl } from '../src/engine.js';
import corpus from './corpus.json';
import { getAdemeFileJson, getResultFile, saveResultFile } from './test-helpers.js';
import { jest } from '@jest/globals';
import { PRECISION } from './constant.js';
describe('Test Open3CL engine compliance on corpus', () => {
/**
* Generate all required files
*/
beforeAll(() => {
jest.spyOn(console, 'warn').mockImplementation(() => {});
corpus.forEach((ademeId) => {
const dpeRequest = getAdemeFileJson(ademeId);
try {
const dpeResult = calcul_3cl(structuredClone(dpeRequest));
saveResultFile(ademeId, dpeResult);
} catch (err) {
console.warn(`3CL Engine failed for file ${ademeId}`, err);
}
});
});
describe.each([
'ep_conso_ch',
'ep_conso_ch_depensier',
'ep_conso_ecs',
'ep_conso_ecs_depensier',
'ep_conso_eclairage',
'ep_conso_auxiliaire_generation_ch',
'ep_conso_auxiliaire_generation_ch_depensier',
'ep_conso_auxiliaire_distribution_ch',
'ep_conso_auxiliaire_generation_ecs',
'ep_conso_auxiliaire_generation_ecs_depensier',
'ep_conso_auxiliaire_distribution_ecs',
'ep_conso_auxiliaire_distribution_fr',
'ep_conso_auxiliaire_ventilation',
'ep_conso_totale_auxiliaire',
'ep_conso_fr',
'ep_conso_fr_depensier',
'ep_conso_5_usages',
'ep_conso_5_usages_m2'
])('check "ep_conso.%s" value', (attr) => {
test.each(corpus)('dpe %s', (ademeId) => {
const exceptedDpe = getAdemeFileJson(ademeId);
const calculatedDpe = getResultFile(ademeId);
expect(calculatedDpe.logement.sortie.ep_conso[attr]).toBeCloseTo(
exceptedDpe.logement.sortie.ep_conso[attr],
PRECISION
);
});
});
test.each(corpus)('check "ep_conso.classe_bilan_dpe" value', (ademeId) => {
const exceptedDpe = getAdemeFileJson(ademeId);
const calculatedDpe = getResultFile(ademeId);
expect(calculatedDpe.logement.sortie.ep_conso['classe_bilan_dpe']).toBe(
exceptedDpe.logement.sortie.ep_conso['classe_bilan_dpe']
);
});
test.each(['2375E2453987C', '2375E2236932V'])(
'"classe_bilan_dpe" should be updated with new values if surface < 40m2',
(ademeId) => {
const exceptedDpe = getAdemeFileJson(ademeId);
const calculatedDpe = getResultFile(ademeId);
// classe_emission_ges should now be E instead of G with new values for surface <= 40m2
expect(calculatedDpe.logement.sortie.ep_conso['classe_bilan_dpe']).toBe('E');
expect(exceptedDpe.logement.sortie.ep_conso['classe_bilan_dpe']).toBe('G');
}
);
});