diff --git a/src/freeDatas2HTMLPagination.ts b/src/Pagination.ts similarity index 100% rename from src/freeDatas2HTMLPagination.ts rename to src/Pagination.ts diff --git a/src/freeDatas2HTML.ts b/src/freeDatas2HTML.ts index 5974ff5..4340ceb 100644 --- a/src/freeDatas2HTML.ts +++ b/src/freeDatas2HTML.ts @@ -2,7 +2,7 @@ const { compare }=require('natural-orderby'); const errors=require("./errors.js"); 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 { ParserForHTML} from "./ParserForHTML"; import { ParserForJSON} from "./ParserForJSON"; @@ -235,7 +235,7 @@ export class FreeDatas2HTML } // Permet l'appel des dépendances via un seul script -export { Pagination } from "./freeDatas2HTMLPagination"; +export { Pagination } from "./Pagination"; export { Render} from "./freeDatas2HTMLRender"; export { Selector } from "./freeDatas2HTMLSelector"; export { SortingField } from "./SortingField"; \ No newline at end of file diff --git a/tests/freeDatas2HTMLSpec.ts b/tests/freeDatas2HTMLSpec.ts index 596189f..3c31cb2 100644 --- a/tests/freeDatas2HTMLSpec.ts +++ b/tests/freeDatas2HTMLSpec.ts @@ -165,5 +165,65 @@ describe("Test du script central de FreeDatas2HTML", () => 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("89ActiniumAcActinide≤ 1"); + getTHLink.click();// tri descendant + getTR=document.querySelectorAll("tr"); + txtDatasViewsElt=getTR[1].innerHTML; + expect(txtDatasViewsElt).toEqual("40ZirconiumZrMétal de transition> 100000"); + getTHLink.click();// de nouveau ascendant + getTR=document.querySelectorAll("tr"); + txtDatasViewsElt=getTR[1].innerHTML; + expect(txtDatasViewsElt).toEqual("89ActiniumAcActinide≤ 1"); + }); + + 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("95AmériciumAmActinideInexistant"); + getTHLink.click();// tri descendant + getTR=document.querySelectorAll("tr"); + txtDatasViewsElt=getTR[1].innerHTML; + expect(txtDatasViewsElt).toEqual("1HydrogèneHNon-métal> 100000"); + getTHLink.click();// de nouveau ascendant + getTR=document.querySelectorAll("tr"); + txtDatasViewsElt=getTR[1].innerHTML; + expect(txtDatasViewsElt).toEqual("95AmériciumAmActinideInexistant"); + }); + + + + }); */ }); \ No newline at end of file