SPB Git

Repository Public

adresse.test.ts 4.9 KB 95 lines typescript

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : UQO Éval — Le Grand Défi Immobilier8 * File             : tests/unit/adresse.test.ts9 * Module           : tests10 * Repository       : https://git.spboucher.ai/uqo-eval-jeux11 * Project Website  : https://jeux.uqo-eval.app12 * Created          : 2026-11-2513 * Last Modified    : 2026-11-2514 *15 * Author           : Simon-Pierre Boucher16 * Position         : Professor of Finance17 * Institution      : Université du Québec en Outaouais (UQO)18 * Organization     : SP Boucher19 * Website          : https://spboucher.ai20 * Git              : https://git.spboucher.ai21 *22 * Preferred Contact: contact@spboucher.ai23 * Development      : dev@spboucher.ai24 * Support          : support@spboucher.ai25 * Security/Admin   : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License          : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243import { describe, expect, it } from "vitest";44import { publicSector, redactStreets, toPublicCard, type PropertySnapshot } from "@jeux/engine";4546describe("aucune adresse ni nom de rue dans la fiche du joueur", () => {47  it("retire les noms de rue français, avec ou sans numéro civique", () => {48    const texte = redactStreets("Superbe propriété située au 123, rue des Érables, à deux pas du parc. Cuisine rénovée et cour arrière intime pour toute la famille.");49    expect(texte).not.toMatch(/Érables|123/);50    expect(texte).toContain("[rue retirée]");51  });5253  it("retire chemins, routes numérotées, avenues et boulevards sans avaler la phrase suivante", () => {54    const texte = redactStreets("Bungalow sur le chemin du Lac-Noir, près de la route 117 et de l'avenue Principale. Terrain boisé, véritable havre de paix.");55    expect(texte).not.toMatch(/Lac-Noir|117|Principale/);56    expect(texte).toContain("Terrain boisé");57  });5859  it("retire les noms de rue anglais", () => {60    const texte = redactStreets("Located at 45 Maple Street near Elm Road, this charming home offers three bedrooms and a large private yard.");61    expect(texte).not.toMatch(/Maple|Elm|45/);62  });6364  it("laisse intact un texte sans adresse, y compris « place de choix »", () => {65    const original = "Condo lumineux au coeur du Plateau, une place de choix à proximité du métro, des cafés et du parc La Fontaine, avec balcon.";66    expect(redactStreets(original)).toBe(original);67  });6869  it("n'affiche un secteur que s'il désigne un quartier, jamais une rue ni une adresse", () => {70    for (const rue of ["Place Renaud", "Rue Principale", "1450 rue Notre-Dame", "Côte Sainte-Catherine", "Chemin du Lac", "Maple Street"]) {71      expect(publicSector(rue), rue).toBeNull();72    }73    for (const quartier of ["Le Plateau-Mont-Royal", "Côte-des-Neiges", "Parc de la Cité", "Chomedey", "Sainte-Foy/Sillery/Cap-Rouge"]) {74      expect(publicSector(quartier), quartier).toBe(quartier);75    }76    expect(publicSector(null)).toBeNull();77  });7879  it("la fiche publique applique ces deux filtres aux instantanés déjà enregistrés", () => {80    const snapshot = {81      category: "unifamiliale", subtype: null, municipality: "Laval", municipalityCode: null, sector: "Place Renaud", regionCode: "13", regionName: "Laval", mrc: null,82      price: 474900, priceObservedAt: "2026-11-01", firstSeenAt: null, priceHistory: [], bedrooms: 3, bathrooms: 1, powderRooms: null, livingAreaSqft: null, lotAreaSqft: 3200,83      yearBuilt: 1972, rooms: null, floors: null, unitFloor: null, garage: null, pool: null, basement: null, heating: null, heatingEnergy: null, siding: null, roofing: null,84      foundation: null, windows: null, parking: null, view: null, waterfront: null, siteFeatures: null, fireplace: null, condoFeesYearly: null, annualRevenue: null,85      municipalTaxes: null, assessment: null, lat: 45.6, lng: -73.75,86      description: "Charmante maison située sur la Place Renaud, à Laval, près de tous les services, avec une grande cour clôturée et un cabanon.",87    } as unknown as PropertySnapshot;88    const card = toPublicCard(snapshot, "graine-secrete");89    expect(card.sector).toBeNull();90    expect(card.description).not.toContain("Renaud");91    const json = JSON.stringify(card);92    expect(json).not.toMatch(/Renaud|https?:|474900/);93  });94});95
Files main
Menu

Theme