Skip to content

Commit

Permalink
test(ui): add render html utils
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Oct 3, 2024
1 parent 2a442db commit 9bdf12e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 39 deletions.
3 changes: 3 additions & 0 deletions packages/~/app/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
"./table": {
"default": "./src/table/index.ts"
},
"./testing": {
"default": "./src/testing/index.ts"
},
"./visually_hidden": {
"default": "./src/visually_hidden/index.ts"
},
Expand Down
68 changes: 31 additions & 37 deletions packages/~/organizations/ui/src/info/About.test.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,38 @@
//

import { renderHTML } from "@~/app.ui/testing";

Check failure on line 3 in packages/~/organizations/ui/src/info/About.test.tsx

View workflow job for this annotation

GitHub Actions / e2e (auth)

Cannot find module '@~/app.ui/testing' or its corresponding type declarations.

Check failure on line 3 in packages/~/organizations/ui/src/info/About.test.tsx

View workflow job for this annotation

GitHub Actions / e2e (moderations)

Cannot find module '@~/app.ui/testing' or its corresponding type declarations.

Check failure on line 3 in packages/~/organizations/ui/src/info/About.test.tsx

View workflow job for this annotation

GitHub Actions / e2e (organizations)

Cannot find module '@~/app.ui/testing' or its corresponding type declarations.

Check failure on line 3 in packages/~/organizations/ui/src/info/About.test.tsx

View workflow job for this annotation

GitHub Actions / e2e (users)

Cannot find module '@~/app.ui/testing' or its corresponding type declarations.
import { expect, test } from "bun:test";
import { Hono } from "hono";
import { jsxRenderer } from "hono/jsx-renderer";
import { About } from "./About";

test("render about section", async () => {
const response = await new Hono()
.get("/", jsxRenderer(), ({ render }) =>
render(
<About
organization={{
cached_activite_principale: "cached_activite_principale",
cached_adresse: "cached_adresse",
cached_categorie_juridique: "cached_categorie_juridique",
cached_code_officiel_geographique:
"cached_code_officiel_geographique",
cached_code_postal: "cached_code_postal",
cached_enseigne: "cached_enseigne",
cached_est_active: true,
cached_etat_administratif: "cached_etat_administratif",
cached_libelle_activite_principale:
"cached_libelle_activite_principale",
cached_libelle_categorie_juridique:
"cached_libelle_categorie_juridique",
cached_libelle_tranche_effectif: "cached_libelle_tranche_effectif",
cached_libelle: "cached_libelle",
cached_nom_complet: "cached_nom_complet",
cached_tranche_effectifs: "cached_tranche_effectifs",
created_at: "2011-11-22 14:34:34.000Z",
id: 42,
siret: "siret",
updated_at: "2011-11-15T13:48:00.000Z",
}}
/>,
),
)
.request("/");
expect(response.status).toBe(200);
// expect(
// await format(await response.text(), { parser: "html" }),
// ).toMatchSnapshot();
expect(
await renderHTML(
<About
organization={{
cached_activite_principale: "cached_activite_principale",
cached_adresse: "cached_adresse",
cached_categorie_juridique: "cached_categorie_juridique",
cached_code_postal: "cached_code_postal",
cached_est_active: true,
cached_nom_complet: "cached_nom_complet",
created_at: "2011-11-22 14:34:34.000Z",
id: 42,
siret: "siret",
cached_code_officiel_geographique:
"cached_code_officiel_geographique",
updated_at: "2011-11-15T13:48:00.000Z",
cached_libelle_activite_principale:
"cached_libelle_activite_principale",
cached_libelle_categorie_juridique:
"cached_libelle_categorie_juridique",
cached_libelle_tranche_effectif: "cached_libelle_tranche_effectif",
cached_libelle: "cached_libelle",
cached_enseigne: "cached_enseigne",
cached_tranche_effectifs: "cached_tranche_effectifs",
cached_etat_administratif: "cached_etat_administratif",
}}
id="about "
/>,
),
).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Bun Snapshot v1, https://goo.gl/fbAQLP

exports[`render about section 1`] = `
"<!doctype html>
<section>
"<section id="about ">
<ul class="list-none pl-0">
<li>
Creation de l&#39;organisation :
Expand Down

0 comments on commit 9bdf12e

Please sign in to comment.