-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtmlElements.test.js
78 lines (69 loc) · 3.32 KB
/
htmlElements.test.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
global.TextEncoder = require("util").TextEncoder;
global.TextDecoder = require("util").TextDecoder;
const fs = require('fs');
const path = require('path');
const { JSDOM } = require('jsdom');
require('@testing-library/jest-dom');
const html = fs.readFileSync(path.resolve(__dirname, '../index.html'), 'utf8');
let dom;
let htmlBody;
let htmlHead;
beforeEach(() => {
dom = new JSDOM(html, { runScripts: 'dangerously' });
htmlBody = dom.window.document.body;
htmlHead = dom.window.document.head;
});
test('vérifie que les identifiants utilisés dans welcome-message-handler.js existent', () => {
const welcomeMessage = htmlBody.querySelector('#welcome-message');
const closeWelcome = htmlBody.querySelector('#close-welcome');
expect(welcomeMessage).toBeInTheDocument();
expect(closeWelcome).toBeInTheDocument();
});
test('vérifie que les identifiants utilisés dans dark-mode.js existent', () => {
const toggleSwitch = htmlBody.querySelector('#dark-mode-toggle');
const homeLogo = htmlBody.querySelector('#home-logo');
const favicon = htmlHead.querySelector('#favicon');
const githubLogo = htmlBody.querySelector('#github-logo');
expect(toggleSwitch).toBeInTheDocument();
expect(homeLogo).toBeInTheDocument();
expect(favicon).toBeInTheDocument();
expect(githubLogo).toBeInTheDocument();
});
test('vérifie que les identifiants utilisés dans form-handler.js existent', () => {
const form = htmlBody.querySelector('#calculette-form');
const resultat = htmlBody.querySelector('#resultat');
const myChart = htmlBody.querySelector('#myChart');
const loyersContainer = htmlBody.querySelector('#loyers-container');
const prixInput = htmlBody.querySelector('#prix');
const notaireInput = htmlBody.querySelector('#notaire');
const coproprieteInput = htmlBody.querySelector('#copropriete');
const tauxAppreciationInput = htmlBody.querySelector('#taux-appreciation');
const tauxLoyerFictifInput = htmlBody.querySelector('#taux-loyer-fictif');
const commissionInput = htmlBody.querySelector('#commission');
const apportInput = htmlBody.querySelector('#apport');
const tauxInput = htmlBody.querySelector('#taux');
const dureePretInput = htmlBody.querySelector('#duree-pret');
const loyerFictifInput = htmlBody.querySelector('#loyer-fictif');
const taxeHabitationInput = htmlBody.querySelector('#taxe-habitation');
const taxeFonciereInput = htmlBody.querySelector('#taxe-fonciere');
const calculerButton = htmlBody.querySelector('#calculer-button');
const rapportBouton = htmlBody.querySelector('#rapport-bouton');
expect(form).toBeInTheDocument();
expect(resultat).toBeInTheDocument();
expect(myChart).toBeInTheDocument();
expect(loyersContainer).toBeInTheDocument();
expect(prixInput).toBeInTheDocument();
expect(notaireInput).toBeInTheDocument();
expect(coproprieteInput).toBeInTheDocument();
expect(tauxAppreciationInput).toBeInTheDocument();
expect(tauxLoyerFictifInput).toBeInTheDocument();
expect(commissionInput).toBeInTheDocument();
expect(apportInput).toBeInTheDocument();
expect(tauxInput).toBeInTheDocument();
expect(dureePretInput).toBeInTheDocument();
expect(loyerFictifInput).toBeInTheDocument();
expect(taxeHabitationInput).toBeInTheDocument();
expect(taxeFonciereInput).toBeInTheDocument();
expect(calculerButton).toBeInTheDocument();
expect(rapportBouton).toBeInTheDocument();
});