<commit_before>import React from "react";
import * as Gatsby from "gatsby";
import { fireEvent, render } from "@testing-library/react";
// Type
import {
  CodeTogetherCurriculumType,
  CodeTogetherSubjectInfoType,
} from "@type/CodeTogetherCurriculum";
// Testing-Component
import { DetailCurriculum } from ".";
// Mock
import { DetailCurriculumQueryResult } from "./DetailCurriculum.test.mock";
// lib
import { TestProvider } from "lib/testUtils";
import { strainAllMdxInfo } from "lib/utils";

describe("<DetailCurriculum>", () => {
  const renderDetailCurriculum = () =>
    render(
      <TestProvider>
        <DetailCurriculum />
      </TestProvider>
    );
  const useStaticQuery = jest.spyOn(Gatsby, "useStaticQuery");
  useStaticQuery.mockImplementation(() => DetailCurriculumQueryResult);
  it("각 탭들이 보여진다.", async () => {
    const { getByText } = renderDetailCurriculum();
    const curriculumInfo: CodeTogetherCurriculumType[] = strainAllMdxInfo(
      DetailCurriculumQueryResult
    );
    const titles = curriculumInfo.map(({ tabName }) => tabName);

    titles.forEach((title: string) => {
      getByText(title);
    });
  });
  it("각 탭들을 클릭하면 클락한 탭에대한 내용들이 보여진다.", async () => {
    const { getByText } = renderDetailCurriculum();
    const curriculumInfo: CodeTogetherCurriculumType[] = strainAllMdxInfo(
      DetailCurriculumQueryResult
    );
    const titles = curriculumInfo.map(({ tabName }) => tabName);
    const subjectList = curriculumInfo.map(({ subjectList }) => subjectList);

    titles.forEach((title, i) => {
      const tabTitle = getByText(title);
      fireEvent.click(tabTitle);

      subjectList[i].forEach(({ name, details }: CodeTogetherSubjectInfoType) => {
        getByText(name);
      });
    });
  });
  it("각 탭들을 클릭하면 탭에 맞는 마스터의 정보가 보여진다.", async () => {
    const { getByText } = renderDetailCurriculum();
    const curriculumInfo: CodeTogetherCurriculumType[] = strainAllMdxInfo(
      DetailCurriculumQueryResult
    );
    const titles = curriculumInfo.map(({ tabName }) => tabName);
    const masters = curriculumInfo.map(({ masterInfo }) => masterInfo);

    titles.forEach((title, i) => {
      const tabTitle = getByText(title);
      fireEvent.click(tabTitle);

      const { name, position, introduce, nutshell } = masters[i];

      getByText(name);
      getByText(position);
      getByText(introduce);
      getByText(nutshell);
    });
  });
});<commit_msg>:white_check_mark: 중복 사용되는 객체를 외부 스코프에서 정의되도록 수정<commit_after>import React from "react";
import * as Gatsby from "gatsby";
import { fireEvent, render } from "@testing-library/react";
// Type
import {
  CodeTogetherCurriculumType,
  CodeTogetherSubjectInfoType,
} from "@type/CodeTogetherCurriculum";
// Testing-Component
import { DetailCurriculum } from ".";
// Mock
import { DetailCurriculumQueryResult } from "./DetailCurriculum.test.mock";
// lib
import { TestProvider } from "lib/testUtils";
import { strainAllMdxInfo } from "lib/utils";

describe("<DetailCurriculum>", () => {
  const renderDetailCurriculum = () =>
    render(
      <TestProvider>
        <DetailCurriculum />
      </TestProvider>
    );
  const useStaticQuery = jest.spyOn(Gatsby, "useStaticQuery");
  useStaticQuery.mockImplementation(() => DetailCurriculumQueryResult);
  const curriculumInfo: CodeTogetherCurriculumType[] = strainAllMdxInfo(
    DetailCurriculumQueryResult
  );
  const titles = curriculumInfo.map(({ tabName }) => tabName);
  const masters = curriculumInfo.map(({ masterInfo }) => masterInfo);
  const subjectList = curriculumInfo.map(({ subjectList }) => subjectList);
  it("각 탭들이 보여진다.", async () => {
    const { getByText } = renderDetailCurriculum();

    titles.forEach((title: string) => {
      getByText(title);
    });
  });
  it("각 탭들을 클릭하면 클락한 탭에대한 내용들이 보여진다.", async () => {
    const { getByText } = renderDetailCurriculum();

    titles.forEach((title, i) => {
      const tabTitle = getByText(title);
      fireEvent.click(tabTitle);

      subjectList[i].forEach(({ name, details }: CodeTogetherSubjectInfoType) => {
        getByText(name);
      });
    });
  });
  it("각 탭들을 클릭하면 탭에 맞는 마스터의 정보가 보여진다.", async () => {
    const { getByText } = renderDetailCurriculum();

    titles.forEach((title, i) => {
      const tabTitle = getByText(title);
      fireEvent.click(tabTitle);

      const { name, position, introduce, nutshell } = masters[i];

      getByText(name);
      getByText(position);
      getByText(introduce);
      getByText(nutshell);
    });
  });
});
{'fraction_non_alphanumeric': 0.14105123087159016, 'fraction_numerical': 0.0, 'mean_word_length': 3.7473684210526317, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1465425', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1575, 'n_words': 289}