Renommage classe gérant la pagination.

This commit is contained in:
Fabrice PENHOËT 2021-10-19 15:40:47 +02:00
parent b3a57c89a3
commit 93264a8b63
3 changed files with 62 additions and 2 deletions

View File

@ -2,7 +2,7 @@ const { compare }=require('natural-orderby');
const errors=require("./errors.js"); const errors=require("./errors.js");
import { Counter, Datas, DatasRenders, DOMElement, Paginations, Parsers, ParseErrors, RemoteSources, Selectors, SortingFields, SortingFunctions } from "./interfaces"; import { Counter, Datas, DatasRenders, DOMElement, Paginations, Parsers, ParseErrors, RemoteSources, Selectors, SortingFields, SortingFunctions } from "./interfaces";
import { Pagination} from "./freeDatas2HTMLPagination"; import { Pagination} from "./Pagination";
import { ParserForCSV} from "./ParserForCSV"; import { ParserForCSV} from "./ParserForCSV";
import { ParserForHTML} from "./ParserForHTML"; import { ParserForHTML} from "./ParserForHTML";
import { ParserForJSON} from "./ParserForJSON"; import { ParserForJSON} from "./ParserForJSON";
@ -235,7 +235,7 @@ export class FreeDatas2HTML
} }
// Permet l'appel des dépendances via un seul script // Permet l'appel des dépendances via un seul script
export { Pagination } from "./freeDatas2HTMLPagination"; export { Pagination } from "./Pagination";
export { Render} from "./freeDatas2HTMLRender"; export { Render} from "./freeDatas2HTMLRender";
export { Selector } from "./freeDatas2HTMLSelector"; export { Selector } from "./freeDatas2HTMLSelector";
export { SortingField } from "./SortingField"; export { SortingField } from "./SortingField";

View File

@ -165,5 +165,65 @@ describe("Test du script central de FreeDatas2HTML", () =>
expect(txtDatasViewsElt).toEqual("118"); expect(txtDatasViewsElt).toEqual("118");
}); });
}); });
/* describe("Action des champs de classement en corrélation avec le convertisseur.", () =>
{
it("Le 1er clic sur l'entête d'une des colonnes doit classer les données dans le sens ascendant, puis descendant et ainsi de suite.", async () =>
{
let sortingField=new SortingField(converter, 2);
sortingField.field2HTML();
converter.datasSortingFields=[sortingField];
let getTHLink=document.querySelector("th a") as HTMLElement;
getTHLink.click();// tri ascendant
let getTR=document.querySelectorAll("tr");
let txtDatasViewsElt=getTR[1].innerHTML;
expect(txtDatasViewsElt).toEqual("<td>89</td><td>Actinium</td><td>Ac</td><td>Actinide</td><td>≤ 1</td>");
getTHLink.click();// tri descendant
getTR=document.querySelectorAll("tr");
txtDatasViewsElt=getTR[1].innerHTML;
expect(txtDatasViewsElt).toEqual("<td>40</td><td>Zirconium</td><td>Zr</td><td>Métal de transition</td><td>&gt; 100000</td>");
getTHLink.click();// de nouveau ascendant
getTR=document.querySelectorAll("tr");
txtDatasViewsElt=getTR[1].innerHTML;
expect(txtDatasViewsElt).toEqual("<td>89</td><td>Actinium</td><td>Ac</td><td>Actinide</td><td>≤ 1</td>");
});
it("Prise en compte d'une fonction spécifique associée au champ de classement.", async () =>
{
const mySort=(a: any, b: any, order: "asc"|"desc"="asc") =>
{
const values=[ "> 100000", "> 1 et < 100 000", "≤ 1", "Traces", "Inexistant"];
if(order === "desc")
values.reverse();
if(values.indexOf(a) > values.indexOf(b))
return -1;
else if(values.indexOf(a) < values.indexOf(b))
return 1;
else
return 0;
};
converter.datasSortingFunctions=[{ datasFieldNb: 4, sort:mySort }];
let sortingField=new SortingField(converter, 4);
sortingField.field2HTML();
converter.datasSortingFields=[sortingField];
let getTHLink=document.querySelector("th a") as HTMLElement;
getTHLink.click();// tri ascendant
let getTR=document.querySelectorAll("tr");
let txtDatasViewsElt=getTR[1].innerHTML;
expect(txtDatasViewsElt).toEqual("<td>95</td><td>Américium</td><td>Am</td><td>Actinide</td><td>Inexistant</td>");
getTHLink.click();// tri descendant
getTR=document.querySelectorAll("tr");
txtDatasViewsElt=getTR[1].innerHTML;
expect(txtDatasViewsElt).toEqual("<td>1</td><td>Hydrogène</td><td>H</td><td>Non-métal</td><td>&gt; 100000</td>");
getTHLink.click();// de nouveau ascendant
getTR=document.querySelectorAll("tr");
txtDatasViewsElt=getTR[1].innerHTML;
expect(txtDatasViewsElt).toEqual("<td>95</td><td>Américium</td><td>Am</td><td>Actinide</td><td>Inexistant</td>");
});
}); */
}); });