feat : overhual [no ci]
This commit is contained in:
+17
-1
@@ -1,4 +1,5 @@
|
||||
import Link from "next/link";
|
||||
import type { ReactElement } from "react";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
@@ -81,6 +82,21 @@ describe("interface translations", () => {
|
||||
expect(html).toContain("Talent Priority");
|
||||
});
|
||||
|
||||
it("localises a lazy child streamed from a server component", () => {
|
||||
const streamedChild = {
|
||||
$$typeof: Symbol.for("react.lazy"),
|
||||
_payload: <Link href="/">Home</Link>,
|
||||
_init: (element: ReactElement) => element,
|
||||
} as unknown as ReactElement;
|
||||
const html = renderToStaticMarkup(
|
||||
<LocaleBoundary locale="en">
|
||||
<Localized attributes={{ "aria-label": "กลับหน้ารวม" }}>{streamedChild}</Localized>
|
||||
</LocaleBoundary>,
|
||||
);
|
||||
expect(html).toContain('aria-label="Back to all guides"');
|
||||
expect(html).toContain("Home");
|
||||
});
|
||||
|
||||
it("preserves custom content while translating only generated headings and conditions", () => {
|
||||
const html = renderToStaticMarkup(<LocaleBoundary locale="en"><input defaultValue="ชื่อภาษาไทย" /><ConditionLabel name="เงื่อนไขของฉัน" index={1} /><ConditionLabel name={null} index={2} /><SectionTitle slug="custom" fallback="หัวข้อของฉัน" /></LocaleBoundary>);
|
||||
expect(html).toContain('value="ชื่อภาษาไทย"');
|
||||
@@ -99,7 +115,7 @@ describe("interface translations", () => {
|
||||
});
|
||||
|
||||
it.each(["th", "en"] as const)("offers both export modes in %s even with no notes", (locale) => {
|
||||
const html = renderToStaticMarkup(<LocaleBoundary locale={locale}><GuideImageExport fileName="test.png">No notes</GuideImageExport></LocaleBoundary>);
|
||||
const html = renderToStaticMarkup(<LocaleBoundary locale={locale}><GuideImageExport allowWithoutNote fileName="test.png">No notes</GuideImageExport></LocaleBoundary>);
|
||||
expect(html).toContain(locale === "en" ? "Export without note" : "ส่งออกภาพโดยไม่รวมโน้ต");
|
||||
expect(html.match(/<button\b/gu)).toHaveLength(2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user