diff --git a/src/components/SEO/index.spec.tsx b/src/components/SEO/index.spec.tsx
new file mode 100644
index 0000000000..0e7f2feb7a
--- /dev/null
+++ b/src/components/SEO/index.spec.tsx
@@ -0,0 +1,171 @@
+import React from "react";
+import { render } from "@testing-library/react";
+import Helmet from "react-helmet";
+import SEO from "./index";
+
+describe("SEO", () => {
+ it("should render metadata", () => {
+ render(
+
+ );
+ const helmet = Helmet.peek();
+ expect(helmet.title).toBe("testTitle");
+ let description = "";
+ let image = "";
+ let ogUrl = "";
+ let ogType = "";
+ let ogTitle = "";
+ let ogDescription = "";
+ let ogImage = "";
+ let fbAppId = "";
+ let twitterCard = "";
+ let twitterCreator = "";
+ let twitterTitle = "";
+ let twitterDescription = "";
+ let twitterImage = "";
+ for (const content of helmet.metaTags) {
+ if (content.name === "description") {
+ description = content.content;
+ }
+ if (content.name === "image") {
+ image = content.content;
+ }
+ if ((content as any).property === "og:url") {
+ ogUrl = content.content;
+ }
+ if ((content as any).property === "og:type") {
+ ogType = content.content;
+ }
+ if ((content as any).property === "og:title") {
+ ogTitle = content.content;
+ }
+ if ((content as any).property === "og:description") {
+ ogDescription = content.content;
+ }
+ if ((content as any).property === "og:image") {
+ ogImage = content.content;
+ }
+ if ((content as any).property === "fb:app_id") {
+ fbAppId = content.content;
+ }
+ if (content.name === "twitter:card") {
+ twitterCard = content.content;
+ }
+ if (content.name === "twitter:creator") {
+ twitterCreator = content.content;
+ }
+ if (content.name === "twitter:title") {
+ twitterTitle = content.content;
+ }
+ if (content.name === "twitter:description") {
+ twitterDescription = content.content;
+ }
+ if (content.name === "twitter:image") {
+ twitterImage = content.content;
+ }
+ }
+ expect(description).toBe("testDescription");
+ expect(image).toBe("https://example.com/test.png");
+ expect(ogUrl).toBe("https://example.com");
+ expect(ogType).toBe("article");
+ expect(ogTitle).toBe("testTitle");
+ expect(ogDescription).toBe("testDescription");
+ expect(ogImage).toBe("https://example.com/test.png");
+ expect(fbAppId).toBe("280941406476272");
+ expect(twitterCard).toBe("summary_large_image");
+ expect(twitterCreator).toBe("@meitante1conan");
+ expect(twitterTitle).toBe("testTitle");
+ expect(twitterDescription).toBe("testDescription");
+ expect(twitterImage).toBe("https://example.com/test.png");
+ });
+ it("should render metadata (not article)", () => {
+ render(
+
+ );
+ const helmet = Helmet.peek();
+ expect(helmet.title).toBe("testTitle");
+ let description = "";
+ let image = "";
+ let ogUrl = "";
+ let ogType = "";
+ let ogTitle = "";
+ let ogDescription = "";
+ let ogImage = "";
+ let fbAppId = "";
+ let twitterCard = "";
+ let twitterCreator = "";
+ let twitterTitle = "";
+ let twitterDescription = "";
+ let twitterImage = "";
+ for (const content of helmet.metaTags) {
+ if (content.name === "description") {
+ description = content.content;
+ }
+ if (content.name === "image") {
+ image = content.content;
+ }
+ if ((content as any).property === "og:url") {
+ ogUrl = content.content;
+ }
+ if ((content as any).property === "og:type") {
+ ogType = content.content;
+ }
+ if ((content as any).property === "og:title") {
+ ogTitle = content.content;
+ }
+ if ((content as any).property === "og:description") {
+ ogDescription = content.content;
+ }
+ if ((content as any).property === "og:image") {
+ ogImage = content.content;
+ }
+ if ((content as any).property === "fb:app_id") {
+ fbAppId = content.content;
+ }
+ if (content.name === "twitter:card") {
+ twitterCard = content.content;
+ }
+ if (content.name === "twitter:creator") {
+ twitterCreator = content.content;
+ }
+ if (content.name === "twitter:title") {
+ twitterTitle = content.content;
+ }
+ if (content.name === "twitter:description") {
+ twitterDescription = content.content;
+ }
+ if (content.name === "twitter:image") {
+ twitterImage = content.content;
+ }
+ }
+ expect(description).toBe("testDescription");
+ expect(image).toBe("https://example.com/test.png");
+ expect(ogUrl).toBe("https://example.com");
+ expect(ogType).toBe("website");
+ expect(ogTitle).toBe("testTitle");
+ expect(ogDescription).toBe("testDescription");
+ expect(ogImage).toBe("https://example.com/test.png");
+ expect(fbAppId).toBe("280941406476272");
+ expect(twitterCard).toBe("summary_large_image");
+ expect(twitterTitle).toBe("testTitle");
+ expect(twitterCreator).toBe("@meitante1conan");
+ expect(twitterDescription).toBe("testDescription");
+ expect(twitterImage).toBe("https://example.com/test.png");
+ });
+});
diff --git a/src/components/Sidebar/Archive/index.spec.tsx b/src/components/Sidebar/Archive/index.spec.tsx
index 9c6d194576..5b934fdb80 100644
--- a/src/components/Sidebar/Archive/index.spec.tsx
+++ b/src/components/Sidebar/Archive/index.spec.tsx
@@ -3,6 +3,8 @@ import { render, screen } from "@testing-library/react";
import Archive from "./index";
import { AllPost } from "../entity";
import { axe } from "jest-axe";
+import ReactGA from "react-ga4";
+import userEvent from "@testing-library/user-event";
describe("Archive", () => {
it("has 1 post", async () => {
@@ -42,6 +44,26 @@ describe("Archive", () => {
expect(screen.getByTestId("Archive")).toHaveTextContent("2022");
expect(screen.getByTestId("Archive")).toHaveTextContent("2021");
});
+ it("click event ga", async () => {
+ const allPosts: AllPost[] = [
+ {
+ node: {
+ frontmatter: {
+ date: new Date("2022-01-01").toString(),
+ tags: ["test1", "test2"],
+ },
+ },
+ },
+ ];
+ render();
+ const mockReactGA = jest.spyOn(ReactGA, "event");
+ await userEvent.click(screen.getByRole("link"));
+ expect(mockReactGA.mock.calls[0][0]).toStrictEqual({
+ category: "Archive",
+ action: "push Archive 2022",
+ });
+ mockReactGA.mockRestore();
+ });
it("should not have basic accessibility issues", async () => {
const allPosts: AllPost[] = [
{