Files
courrier/tests/test_ordre_tri.py
T

27 lines
976 B
Python

from pathlib import Path
STATIC = Path(__file__).resolve().parent.parent / "app" / "static"
def _js():
return (STATIC / "app.js").read_text(encoding="utf-8")
def test_tri_du_jour_du_plus_recent_au_plus_ancien():
"""Les mails du jour sont triés par date décroissante (b comparé à a)."""
js = _js()
assert "S.mails = (r.mails || []).map(normaliser).sort(function (a, b) { return String(b.date).localeCompare(String(a.date)); });" in js
assert "String(a.date).localeCompare(String(b.date))" not in js
def test_repartition_du_jour_par_nombre_de_mails_decroissant():
"""Tous reste en tête, puis catégories par nombre de mails décroissant, égalité = ordre d'origine."""
js = _js()
assert "return y.n - x.n || x.rang - y.rang;" in js
assert js.index("nom: 'Tous'") < js.index("y.n - x.n")
def test_groupes_categories_meme_classement():
js = _js()
assert "(cc[y.c.nom] || 0) - (cc[x.c.nom] || 0) || x.rang - y.rang" in js