Compare commits
5 Commits
8e4f572c66
...
d56473ff41
Author | SHA1 | Date | |
---|---|---|---|
d56473ff41 | |||
e5e265d061 | |||
bd7d669af1 | |||
34848f3d0c | |||
d7ddffa90d |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
coverage/
|
119
public/datas/elements-chimiques.csv
Normal file
119
public/datas/elements-chimiques.csv
Normal file
@ -0,0 +1,119 @@
|
||||
Z (numéro atomique),Élément,Symbole,Famille,Abondance des éléments dans la croûte terrestre (μg/k)
|
||||
1,Hydrogène,H,Non-métal,1400000
|
||||
2,Hélium,He,Gaz noble,8
|
||||
3,Lithium,Li,Métal alcalin,20000
|
||||
4,Béryllium,Be,Métal alcalino-terreux,2800
|
||||
5,Bore,B,Métalloïde,10000
|
||||
6,Carbone,C,Non-métal,200000
|
||||
7,Azote,N,Non-métal,19000
|
||||
8,Oxygène,O,Non-métal,461000000
|
||||
9,Fluor,F,Halogène,585000
|
||||
10,Néon,Ne,Gaz noble,5
|
||||
11,Sodium,Na,Métal alcalin,23600000
|
||||
12,Magnésium,Mg,Métal alcalino-terreux,23300000
|
||||
13,Aluminium,Al,Métal pauvre,82300000
|
||||
14,Silicium,Si,Métalloïde,282000000
|
||||
15,Phosphore,P,Non-métal,1050000
|
||||
16,Soufre,S,Non-métal,350000
|
||||
17,Chlore,Cl,Halogène,145000
|
||||
18,Argon,Ar,Gaz noble,3500
|
||||
19,Potassium,K,Métal alcalin,20900000
|
||||
20,Calcium,Ca,Métal alcalino-terreux,41500000
|
||||
21,Scandium,Sc,Métal de transition,22000
|
||||
22,Titane,Ti,Métal de transition,5650000
|
||||
23,Vanadium,V,Métal de transition,120000
|
||||
24,Chrome,Cr,Métal de transition,102000
|
||||
25,Manganèse,Mn,Métal de transition,950000
|
||||
26,Fer,Fe,Métal de transition,56300000
|
||||
27,Cobalt,Co,Métal de transition,25000
|
||||
28,Nickel,Ni,Métal de transition,84000
|
||||
29,Cuivre,Cu,Métal de transition,60000
|
||||
30,Zinc,Zn,Métal pauvre,70000
|
||||
31,Gallium,Ga,Métal pauvre,19000
|
||||
32,Germanium,Ge,Métalloïde,1500
|
||||
33,Arsenic,As,Métalloïde,1800
|
||||
34,Sélénium,Se,Non-métal,50
|
||||
35,Brome,Br,Halogène,2400
|
||||
36,Krypton,Kr,gaz rare,"0,1"
|
||||
37,Rubidium,Rb,Métal alcalin,90000
|
||||
38,Strontium,Sr,Métal alcalino-terreux,370000
|
||||
39,Yttrium,Y,Métal de transition,33000
|
||||
40,Zirconium,Zr,Métal de transition,165000
|
||||
41,Niobium,Nb,Métal de transition,20000
|
||||
42,Molybdène,Mo,Métal de transition,1200
|
||||
43,Technétium,Tc,Métal de transition,Traces
|
||||
44,Ruthénium,Ru,Métal de transition,1
|
||||
45,Rhodium,Rh,Métal de transition,1
|
||||
46,Palladium,Pd,Métal de transition,15
|
||||
47,Argent,Ag,Métal de transition,75
|
||||
48,Cadmium,Cd,Métal pauvre,150
|
||||
49,Indium,In,Métal pauvre,250
|
||||
50,Étain,Sn,Métal pauvre,2300
|
||||
51,Antimoine,Sb,Métalloïde,200
|
||||
52,Tellure,Te,Métalloïde,1
|
||||
53,Iode,I,Halogène,450
|
||||
54,Xénon,Xe,gaz rare,"0,03"
|
||||
55,Césium,Cs,Métal alcalin,3000
|
||||
56,Baryum,Ba,Métal alcalino-terreux,425000
|
||||
57,Lanthane,La,Lanthanide,39000
|
||||
58,Cérium,Ce,Lanthanide,66500
|
||||
59,Praséodyme,Pr,Lanthanide,9200
|
||||
60,Néodyme,Nd,Lanthanide,41500
|
||||
61,Prométhium,Pm,Lanthanide,Traces
|
||||
62,Samarium,Sm,Lanthanide,7050
|
||||
63,Europium,Eu,Lanthanide,2000
|
||||
64,Gadolinium,Gd,Lanthanide,6200
|
||||
65,Terbium,Tb,Lanthanide,1200
|
||||
66,Dysprosium,Dy,Lanthanide,5200
|
||||
67,Holmium,Ho,Lanthanide,1300
|
||||
68,Erbium,Er,Lanthanide,3500
|
||||
69,Thulium,Tm,Lanthanide,520
|
||||
70,Ytterbium,Yb,Lanthanide,3200
|
||||
71,Lutécium,Lu,Lanthanide,800
|
||||
72,Hafnium,Hf,Métal de transition,3000
|
||||
73,Tantale,Ta,Métal de transition,2000
|
||||
74,Tungstène,W,Métal de transition,1250
|
||||
75,Rhénium,Re,Métal de transition,"0,7"
|
||||
76,Osmium,Os,Métal de transition,"1,5"
|
||||
77,Iridium,Ir,Métal de transition,1
|
||||
78,Platine,Pt,Métal de transition,5
|
||||
79,Or,Au,Métal de transition,4
|
||||
80,Mercure,Hg,Métal pauvre,85
|
||||
81,Thallium,Tl,Métal pauvre,850
|
||||
82,Plomb,Pb,Métal pauvre,14000
|
||||
83,Bismuth,Bi,Métal pauvre,"8,5"
|
||||
84,Polonium,Po,Métal pauvre,200×10−9
|
||||
85,Astate,At,Métalloïde,Traces
|
||||
86,Radon,Rn,Gaz noble,400×10−12
|
||||
87,Francium,Fr,Métal alcalin,Traces
|
||||
88,Radium,Ra,Métal alcalino-terreux,900×10−6
|
||||
89,Actinium,Ac,Actinide,550×10−9
|
||||
90,Thorium,Th,Actinide,9600
|
||||
91,Protactinium,Pa,Actinide,"1,4×10−3 "
|
||||
92,Uranium,U,Actinide,2700
|
||||
93,Neptunium,Np,Actinide,Traces
|
||||
94,Plutonium,Pu,Actinide,Traces
|
||||
95,Américium,Am,Actinide,—
|
||||
96,Curium,Cm,Actinide,—
|
||||
97,Berkélium,Bk,Actinide,—
|
||||
98,Californium,Cf,Actinide,—
|
||||
99,Einsteinium,Es,Actinide,—
|
||||
100,Fermium,Fm,Actinide,—
|
||||
101,Mendélévium,Md,Actinide,—
|
||||
102,Nobélium,No,Actinide,—
|
||||
103,Lawrencium,Lr,Actinide,—
|
||||
104,Rutherfordium,Rf,Métal de transition,—
|
||||
105,Dubnium,Db,Métal de transition,—
|
||||
106,Seaborgium,Sg,Métal de transition,—
|
||||
107,Bohrium,Bh,Métal de transition,—
|
||||
108,Hassium,Hs,Métal de transition,—
|
||||
109,Meitnérium,Mt,Indéfinie,—
|
||||
110,Darmstadtium,Ds,Indéfinie,—
|
||||
111,Roentgenium,Rg,Indéfinie,—
|
||||
112,Copernicium,Cn,Métal de transition,—
|
||||
113,Nihonium,Nh,Indéfinie,—
|
||||
114,Flérovium,Fl,Indéfinie,—
|
||||
115,Moscovium,Mc,Indéfinie,—
|
||||
116,Livermorium,Lv,Indéfinie,—
|
||||
117,Tennesse,Ts,Indéfinie,—
|
||||
118,Oganesson,Og,Indéfinie,—
|
|
18
public/index.html
Normal file
18
public/index.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="Page d'exemple simple d'utilisaion du script freeCSV2HTML.">
|
||||
<meta name="robots" content="noindex">
|
||||
<script src="JS/firstExample.app.js" defer></script>
|
||||
<title>freeCSV2HTML (démo utilisation simple)</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>freeCSV2HTML</h1>
|
||||
<article id="datas">
|
||||
<p>Si tout se passe bien, ce texte sera remplacé par un tableau de données extraites du fichier csv.</p>
|
||||
</article>
|
||||
<aside><p>Les données affichées viennent d'un fichier csv reprennant une partie des informations trouvées <a href="https://fr.wikipedia.org/wiki/%C3%89l%C3%A9ment_chimique#Caract%C3%A9ristiques_des_diff%C3%A9rents_%C3%A9l%C3%A9ments">sur Wikipédia</a>.</p></aside>
|
||||
</body>
|
||||
</html>
|
5
src/errors.js
Normal file
5
src/errors.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports =
|
||||
{
|
||||
elementNotFound : "Aucun élément HTML trouvé dans la page pour l'id : ",
|
||||
urlNotValid: "L'url fournie pour le fichier CSS n 'est pas correcte : ",
|
||||
};
|
@ -0,0 +1,31 @@
|
||||
const errors=require("./errors.js");
|
||||
|
||||
interface selectors
|
||||
{
|
||||
colCSV: number;
|
||||
idElt: string;
|
||||
eltDOM?: HTMLElement;
|
||||
}
|
||||
|
||||
export class freeCSV2HTML
|
||||
{
|
||||
private _datasEltId: string = "";
|
||||
private _datasUrl: string = "";
|
||||
private _datasSelectors: selectors[] = [];
|
||||
|
||||
set datasEltId(id: string)
|
||||
{
|
||||
this._datasEltId=id;
|
||||
}
|
||||
|
||||
set datasUrl(url: string)
|
||||
{
|
||||
this._datasUrl=url;
|
||||
}
|
||||
|
||||
set datasSelectors(selectors: selectors[])
|
||||
{
|
||||
this._datasSelectors=selectors;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
import { freeCSV2HTML } from "../src/freeCSV2HTML";
|
||||
const errors=require("../src/errors.js");
|
||||
|
||||
describe("freeCSV2HTML", function()
|
||||
{
|
||||
let converter: freeCSV2HTML;
|
||||
const fixture="<div id='fixture'><div id='selectro1'></div><div id='selector2'></div><div id='datas'></div></div>";
|
||||
|
||||
beforeEach(function()
|
||||
{
|
||||
converter=new freeCSV2HTML();
|
||||
document.body.insertAdjacentHTML('afterbegin', fixture);
|
||||
});
|
||||
|
||||
afterEach(function()
|
||||
{
|
||||
document.body.removeChild(document.getElementById('fixture'));
|
||||
});
|
||||
|
||||
it("Doit être une instance de freeCSV2HTML", function()
|
||||
{
|
||||
expect(converter).toBeInstanceOf(freeCSV2HTML);
|
||||
});
|
||||
|
||||
describe("Setting freeCSV2HTML", function()
|
||||
{
|
||||
it("Doit générer une erreur s'il n'y a pas d'élément dans la page pour l'id fourni pour recevoir les données.", function()
|
||||
{
|
||||
expect(function() { return converter.datasEltId="dontExistId"; }).toThrowError(errors.elementNotFound+"dontExistId");
|
||||
});
|
||||
|
||||
it("Ne doit pas générer une erreur s'il y a un élément dans la page pour l'id fourni pour recevoir les données.", function()
|
||||
{
|
||||
expect(function() { return converter.datasEltId="datas"; }).not.toThrowError();
|
||||
});
|
||||
|
||||
it("Doit générer une erreur si l'url fournie pour le fichier csv n'est pas valide.", function()
|
||||
{
|
||||
expect(function() { return converter.datasUrl="http:/localhost:8080/datas/elements-chimiques.csv"; }).toThrowError(errors.urlNotValid);
|
||||
});
|
||||
|
||||
it("Ne doit pas générer une erreur si l'url fournie pour le fichier csv est pas valide.", function()
|
||||
{
|
||||
expect(function() { return converter.datasUrl="http://localhost:8080/datas/elements-chimiques.csv"; }).not.toThrowError();
|
||||
});
|
||||
|
||||
it("Doit générer une erreur s'il n'y a pas d'éléments dans la page pour les ids fournis pour recevoir les sélecteurs.", function()
|
||||
{
|
||||
expect(function() { return converter.datasSelectors=[{ colCSV:2, idElt:"selector2"},{ colCSV:3, idElt:"selector3"}]; }).toThrowError(errors.elementNotFound+"select3");
|
||||
});
|
||||
|
||||
it("Ne doit pas générer une erreur s'il y a bien un élément dans la page pour chaque id fourni pour recevoir un sélecteur.", function()
|
||||
{
|
||||
expect(function() { return converter.datasSelectors=[{ colCSV:2, idElt:"selector1"},{ colCSV:3, idElt:"selector2"}]; }).not.toThrowError();
|
||||
});
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user