From 5d949d89f521db0fd412ceaa5e794f0f3928a3a9 Mon Sep 17 00:00:00 2001 From: Shamzic Date: Wed, 1 Jan 2025 11:15:46 +0100 Subject: [PATCH 1/3] feat: improve description test --- test/AidesVeloEngine.test.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/test/AidesVeloEngine.test.ts b/test/AidesVeloEngine.test.ts index b1b7f99..a2399b0 100644 --- a/test/AidesVeloEngine.test.ts +++ b/test/AidesVeloEngine.test.ts @@ -1,4 +1,5 @@ import { Aide, AideRuleNames, AidesVeloEngine } from "../src"; +import { Localisation } from "../src/data"; import { describe, expect, it } from "vitest"; describe("AidesVeloEngine", () => { @@ -93,19 +94,24 @@ describe("AidesVeloEngine", () => { }); it("should have a description", function () { - const engine = globalTestEngine.shallowCopy(); - const allAides = engine.getAllAidesIn(); - allAides.forEach((aide) => { - expect(typeof aide.description, 'Error description empty ' + aide.title).toBe("string") + const engine = globalTestEngine.shallowCopy(); + const countries: Array = ["france", "monaco", "luxembourg"]; + + countries.forEach(country => { + const allAides = engine.getAllAidesIn(country); + allAides.forEach((aide) => { + expect(typeof aide.description, `Description should be a string for benefit: ${aide.title} (${country})`).toBe("string"); + expect(aide.description.length, `Description cannot be empty for benefit: ${aide.title} (${country})`).toBeGreaterThan(0); const innerText = aide.description .replace(/<\/?[^>]+>/gi, "") .replace(/\s\s+/g, " ") - .trim() - expect(innerText.length).toBeGreaterThanOrEqual(10) + .trim(); + expect(innerText.length, `Description must be at least 10 characters for benefit: ${aide.title} (${country})`).toBeGreaterThanOrEqual(10); if (innerText.length > 420) { - console.warn(`Text length (${innerText.length}) exceeds maximum allowed length of 420 characters`); + console.warn(`Description text length (${innerText.length}) exceeds maximum allowed length of 420 characters for benefit: ${aide.title} (${country})`); } - }); + }); + }); }) it("should return all aids in Luxembourg if specified", () => { From eb17d333306ff4594937a43d920446895ff30672 Mon Sep 17 00:00:00 2001 From: Shamzic Date: Wed, 1 Jan 2025 11:23:11 +0100 Subject: [PATCH 2/3] refactor: add description for monaco benefit --- src/rules/aides.publicodes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rules/aides.publicodes b/src/rules/aides.publicodes index dab1eab..c3b5270 100644 --- a/src/rules/aides.publicodes +++ b/src/rules/aides.publicodes @@ -9064,6 +9064,8 @@ aides . montmorillon: aides . monaco: remplace: commune titre: Monaco + description: > + Monaco subventionne l'achat d'un vélo électrique neuf. applicable si: toutes ces conditions: - vélo . électrique From 34b1b3a75a663113835d8c0be571125339958838 Mon Sep 17 00:00:00 2001 From: Shamzic Date: Wed, 1 Jan 2025 11:25:06 +0100 Subject: [PATCH 3/3] chore: npx changeset --- .changeset/lazy-peaches-sing.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/lazy-peaches-sing.md diff --git a/.changeset/lazy-peaches-sing.md b/.changeset/lazy-peaches-sing.md new file mode 100644 index 0000000..9ae4b7c --- /dev/null +++ b/.changeset/lazy-peaches-sing.md @@ -0,0 +1,5 @@ +--- +"@betagouv/aides-velo": patch +--- + +Improve description test