Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions tests/components/notes/NoteCreateContainer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "@/hooks/queries/notes";
import NoteCreateContainer from "@/app/(protected)/notes/_components/NoteCreateContainer";
import { renderWithQueryClient } from "tests/test-utils";
import { localStorageMock } from "tests/mocks/localStorageMock";

const replaceMock = jest.fn();

Expand All @@ -19,22 +20,6 @@ jest.mock("@/lib/toast");
jest.mock("@/hooks/queries/todos");
jest.mock("@/hooks/queries/notes");

const localStorageMock = (() => {
let store: Record<string, string> = {};
return {
getItem: (key: string) => store[key] || null,
setItem: (key: string, value: string) => {
store[key] = value;
},
removeItem: (key: string) => {
delete store[key];
},
clear: () => {
store = {};
},
};
})();

Object.defineProperty(window, "localStorage", {
value: localStorageMock,
});
Expand Down Expand Up @@ -114,7 +99,7 @@ describe("NoteCreateContainer", () => {
expect(titleInput).toHaveValue("์ฒซ ๋ฒˆ์งธ ๋…ธํŠธ");
});

it("๋งํฌ ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ fetch๊ฐ€ ํ˜ธ์ถœ๋œ๋‹ค", async () => {
it("๋งํฌ ์ž…๋ ฅ ์‹œ ์ž…๋ ฅํ•œ URL๋กœ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ fetch๊ฐ€ ํ˜ธ์ถœ๋œ๋‹ค", async () => {
const user = userEvent.setup();
const { mockLinkMetadataMutation } = setup();

Expand Down
17 changes: 1 addition & 16 deletions tests/components/notes/NoteEditContainer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "@/hooks/queries/notes";
import NoteEditContainer from "@/app/(protected)/notes/_components/NoteEditContainer";
import { renderWithQueryClient } from "tests/test-utils";
import { localStorageMock } from "tests/mocks/localStorageMock";

const replaceMock = jest.fn();

Expand All @@ -18,22 +19,6 @@ jest.mock("next/navigation", () => ({
jest.mock("@/lib/toast");
jest.mock("@/hooks/queries/notes");

const localStorageMock = (() => {
let store: Record<string, string> = {};
return {
getItem: (key: string) => store[key] || null,
setItem: (key: string, value: string) => {
store[key] = value;
},
removeItem: (key: string) => {
delete store[key];
},
clear: () => {
store = {};
},
};
})();

Object.defineProperty(window, "localStorage", {
value: localStorageMock,
});
Expand Down
15 changes: 15 additions & 0 deletions tests/mocks/localStorageMock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const localStorageMock = (() => {
let store: Record<string, string> = {};
return {
getItem: (key: string) => store[key] || null,
setItem: (key: string, value: string) => {
store[key] = value;
},
removeItem: (key: string) => {
delete store[key];
},
clear: () => {
store = {};
},
};
})();