-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathopen3cl-sorties-cout.spec.js
52 lines (50 loc) · 1.61 KB
/
open3cl-sorties-cout.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
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([
'cout_ch',
'cout_ch_depensier',
'cout_ecs',
'cout_ecs_depensier',
'cout_eclairage',
'cout_auxiliaire_generation_ch',
'cout_auxiliaire_generation_ch_depensier',
'cout_auxiliaire_distribution_ch',
'cout_auxiliaire_generation_ecs',
'cout_auxiliaire_generation_ecs_depensier',
'cout_auxiliaire_distribution_ecs',
'cout_auxiliaire_distribution_fr',
'cout_auxiliaire_ventilation',
'cout_total_auxiliaire',
'cout_fr',
'cout_fr_depensier',
'cout_5_usages'
])('check "cout.%s" value', (attr) => {
test.each(corpus)('dpe %s', (ademeId) => {
const exceptedDpe = getAdemeFileJson(ademeId);
const calculatedDpe = getResultFile(ademeId);
expect(calculatedDpe.logement.sortie.cout[attr]).toBeCloseTo(
exceptedDpe.logement.sortie.cout[attr],
PRECISION
);
});
});
});