-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathopen3cl-validators.spec.js
143 lines (117 loc) · 4.33 KB
/
open3cl-validators.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import { calcul_3cl } from '../src/engine.js';
import corpus from './corpus.json';
import { jest } from '@jest/globals';
import { getAdemeFileJson, getResultFile, saveResultFile } from './test-helpers.js';
describe('Test DPE validators', () => {
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('DPE must be parsed without plancher_bas if pont_thermique_collection is empty or does not concern plancher_bas', () => {
const dpe = getAdemeFileJson('2187E0981996L');
dpe.logement.enveloppe.plancher_bas_collection = null;
let calculatedDpe = calcul_3cl(dpe);
expect(calculatedDpe).toBeNull();
dpe.logement.enveloppe.plancher_bas_collection = null;
dpe.logement.enveloppe.pont_thermique_collection = null;
calculatedDpe = calcul_3cl(dpe);
expect(calculatedDpe).toBeNull();
dpe.logement.enveloppe.plancher_bas_collection = null;
dpe.logement.sortie.deperdition.deperdition_plancher_bas = 0;
calculatedDpe = calcul_3cl(dpe);
expect(calculatedDpe).not.toBeNull();
dpe.logement.enveloppe.plancher_bas_collection = null;
dpe.logement.enveloppe.pont_thermique_collection = {};
calculatedDpe = calcul_3cl(dpe);
expect(calculatedDpe).not.toBeNull();
dpe.logement.enveloppe.plancher_bas_collection = null;
dpe.logement.enveloppe.pont_thermique_collection = {
pont_thermique: [
{
donnee_entree: {
description: '',
enum_methode_saisie_pont_thermique_id: 1,
enum_type_liaison_id: 1
}
}
]
};
calculatedDpe = calcul_3cl(dpe);
expect(calculatedDpe).toBeNull();
dpe.logement.enveloppe.plancher_bas_collection = null;
dpe.logement.enveloppe.pont_thermique_collection = {
pont_thermique: [
{
donnee_entree: {
description: '',
enum_methode_saisie_pont_thermique_id: 1,
enum_type_liaison_id: 3
}
}
]
};
calculatedDpe = calcul_3cl(dpe);
expect(calculatedDpe).not.toBeNull();
});
test('DPE must be parsed without plancher_haut if pont_thermique_collection is empty or does not concern plancher_haut', () => {
const dpe = getAdemeFileJson('2187E0981996L');
dpe.logement.enveloppe.plancher_haut_collection = null;
let calculatedDpe = calcul_3cl(dpe);
expect(calculatedDpe).toBeNull();
dpe.logement.enveloppe.plancher_haut_collection = null;
dpe.logement.enveloppe.pont_thermique_collection = null;
calculatedDpe = calcul_3cl(dpe);
expect(calculatedDpe).toBeNull();
dpe.logement.enveloppe.plancher_haut_collection = null;
dpe.logement.sortie.deperdition.deperdition_plancher_haut = 0;
calculatedDpe = calcul_3cl(dpe);
expect(calculatedDpe).not.toBeNull();
dpe.logement.enveloppe.plancher_haut_collection = null;
dpe.logement.enveloppe.pont_thermique_collection = {};
calculatedDpe = calcul_3cl(dpe);
expect(calculatedDpe).not.toBeNull();
dpe.logement.enveloppe.plancher_haut_collection = null;
dpe.logement.enveloppe.pont_thermique_collection = {
pont_thermique: [
{
donnee_entree: {
description: '',
enum_methode_saisie_pont_thermique_id: 1,
enum_type_liaison_id: 3
}
}
]
};
calculatedDpe = calcul_3cl(dpe);
expect(calculatedDpe).toBeNull();
dpe.logement.enveloppe.plancher_haut_collection = null;
dpe.logement.enveloppe.pont_thermique_collection = {
pont_thermique: [
{
donnee_entree: {
description: '',
enum_methode_saisie_pont_thermique_id: 1,
enum_type_liaison_id: 1
}
}
]
};
calculatedDpe = calcul_3cl(dpe);
expect(calculatedDpe).not.toBeNull();
});
test.each(['2475E3702442Q', '2492E1256472N', '2494E3676842T'])(
'DPE %ademeId should be parsed without plancher_bas or plancher_haut',
(ademeId) => {
const calculatedDpe = getResultFile(ademeId);
expect(calculatedDpe).not.toBeNull();
}
);
});