This commit is contained in:
@@ -4,6 +4,7 @@ import { buildDefaultSiteSettings } from "../lib/site-settings";
|
||||
import {
|
||||
applyTitleTemplateFn,
|
||||
buildAppMetadataFromConfig,
|
||||
buildLocaleAlternates,
|
||||
buildLocalizedMetadataFromConfig,
|
||||
} from "../lib/metadata";
|
||||
|
||||
@@ -96,4 +97,44 @@ describe("metadata helpers", () => {
|
||||
|
||||
expect(metadata.title).toBe("اسم الموقع");
|
||||
});
|
||||
|
||||
it("builds alternates and canonical from the runtime default locale", () => {
|
||||
const alternates = buildLocaleAlternates("/about", "ar");
|
||||
|
||||
expect(alternates.canonical).toBe("https://mohfarawati.de/about");
|
||||
expect(alternates.languages.ar).toBe("https://mohfarawati.de/about");
|
||||
expect(alternates.languages.de).toBe("https://mohfarawati.de/de/about");
|
||||
expect(alternates.languages["x-default"]).toBe("https://mohfarawati.de/about");
|
||||
});
|
||||
|
||||
it("builds localized metadata urls against the configured default locale", () => {
|
||||
const settings = buildDefaultSiteSettings("Studio Moh");
|
||||
settings.defaultLocale = "ar";
|
||||
|
||||
const metadata = buildLocalizedMetadataFromConfig({
|
||||
settings,
|
||||
bindings: {
|
||||
siteLogoLight: null,
|
||||
siteLogoDark: null,
|
||||
favicon: null,
|
||||
defaultOgImage: null,
|
||||
},
|
||||
locale: "de",
|
||||
pathname: "/about",
|
||||
title: "About",
|
||||
});
|
||||
|
||||
expect(metadata.alternates).toMatchObject({
|
||||
canonical: "https://mohfarawati.de/about",
|
||||
languages: {
|
||||
ar: "https://mohfarawati.de/about",
|
||||
de: "https://mohfarawati.de/de/about",
|
||||
en: "https://mohfarawati.de/en/about",
|
||||
"x-default": "https://mohfarawati.de/about",
|
||||
},
|
||||
});
|
||||
expect(metadata.openGraph).toMatchObject({
|
||||
url: "https://mohfarawati.de/de/about",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user