-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathopen3cl-nadeq.spec.js
29 lines (25 loc) · 1022 Bytes
/
open3cl-nadeq.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
import { calcul_3cl } from '../src/engine.js';
import corpus from './corpus.json';
import { getAdemeFileJson, saveResultFile } from './test-helpers.js';
import { jest } from '@jest/globals';
import { Nadeq } from '../src/11_nadeq.js';
describe('Test Open3CL engine compliance on corpus', () => {
const nadeq = new Nadeq();
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);
}
});
});
test.each(corpus)('check nadeq for dpe %s', (ademeId) => {
const exceptedDpe = getAdemeFileJson(ademeId);
const calculatedNadeq = nadeq.calculateNadeq(exceptedDpe.logement);
expect(calculatedNadeq).toBeCloseTo(exceptedDpe.logement.sortie.apport_et_besoin.nadeq, 2);
});
});