-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix/game-screen/typing
- Loading branch information
Showing
53 changed files
with
3,986 additions
and
626 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
API_URL=http://localhost:8080 | ||
NEXT_PUBLIC_API_URL=http://localhost:8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { LoginModalPresenter } from "@/components/molecules/LoginModal"; | ||
import { describe, expect, it, jest } from "@jest/globals"; | ||
import { render, screen, fireEvent } from "@testing-library/react"; | ||
|
||
describe("LoginModal", () => { | ||
const mockDispatchAction = jest.fn(); | ||
const mockState = {}; | ||
const mockPending = false; | ||
|
||
it("renders input form in LoginModal", () => { | ||
const loginModal = render( | ||
<LoginModalPresenter | ||
isOpen={true} | ||
onClose={() => {}} | ||
state={mockState} | ||
dispatchAction={mockDispatchAction} | ||
pending={mockPending} | ||
/> | ||
); | ||
|
||
const textbox = screen.getByRole("textbox"); | ||
expect(textbox).toBeInTheDocument(); | ||
}); | ||
|
||
it("renders button in LoginModal", () => { | ||
const loginModal = render( | ||
<LoginModalPresenter | ||
isOpen={true} | ||
onClose={() => {}} | ||
state={mockState} | ||
dispatchAction={mockDispatchAction} | ||
pending={mockPending} | ||
/> | ||
); | ||
|
||
const submitButton = screen.getByRole("submit"); | ||
expect(submitButton).toBeInTheDocument(); | ||
}); | ||
|
||
it("DO NOT calls dispatchAction when user input is empty", () => { | ||
const loginModal = render( | ||
<LoginModalPresenter | ||
isOpen={true} | ||
onClose={() => {}} | ||
state={mockState} | ||
dispatchAction={mockDispatchAction} | ||
pending={mockPending} | ||
/> | ||
); | ||
|
||
const submitButton = screen.getByRole("submit"); | ||
fireEvent.click(submitButton); | ||
expect(mockDispatchAction).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it("DO NOT calls dispatchAction when user input is less than 8 characters", () => { | ||
const loginModal = render( | ||
<LoginModalPresenter | ||
isOpen={true} | ||
onClose={() => {}} | ||
state={mockState} | ||
dispatchAction={mockDispatchAction} | ||
pending={mockPending} | ||
/> | ||
); | ||
|
||
const textbox = screen.getByRole("textbox"); | ||
fireEvent.change(textbox, { target: { value: "1111" } }); | ||
fireEvent.click(screen.getByRole("submit")); | ||
expect(mockDispatchAction).not.toHaveBeenCalled(); | ||
}); | ||
|
||
//NOTE: 本来ならば、ここで正常系のテストを書きたいが、正常系はAPIリクエストを行うため、テストが困難である。 | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { UserCardPresenter } from "@/components/molecules/UserCard"; | ||
import { describe, expect, it } from "@jest/globals"; | ||
import { render, screen } from "@testing-library/react"; | ||
import type { User } from "@/types/user"; | ||
|
||
describe("UserCard", () => { | ||
const mockUser: User = { | ||
handleName: "しずっぴー", | ||
studentNumber: "B1234567", | ||
id: "1", | ||
}; | ||
|
||
it("renders UserCard", () => { | ||
const userCard = render(<UserCardPresenter user={mockUser} />); | ||
|
||
const avatar = screen.getByRole("img"); | ||
expect(avatar).toBeInTheDocument(); | ||
}); | ||
|
||
it("renders UserCard with user data", () => { | ||
const userCard = render(<UserCardPresenter user={mockUser} />); | ||
|
||
const name = screen.getByText(/名前:/); | ||
const studentNumber = screen.getByText(/学籍番号:/); | ||
expect(name).toHaveTextContent(mockUser.handleName); | ||
expect(studentNumber).toHaveTextContent(mockUser.studentNumber); | ||
}); | ||
|
||
it("renders UserCard with default data", () => { | ||
const userCard = render(<UserCardPresenter user={null as any} />); | ||
|
||
const name = screen.getByText(/名前:/); | ||
const studentNumber = screen.getByText(/学籍番号:/); | ||
expect(name).toHaveTextContent("ログインしていません"); | ||
expect(studentNumber).toHaveTextContent("未ログイン"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* For a detailed explanation regarding each configuration property, visit: | ||
* https://jestjs.io/docs/configuration | ||
*/ | ||
const nextJest = require("next/jest"); | ||
|
||
/** @type {import('jest').Config} */ | ||
const config = { | ||
coverageProvider: "v8", | ||
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"], | ||
testEnvironment: "jsdom", | ||
}; | ||
|
||
const createJestConfig = nextJest({ | ||
dir: "./", | ||
}); | ||
|
||
module.exports = createJestConfig(config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "@testing-library/jest-dom/jest-globals"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.