Skip to content

Commit

Permalink
심화 과제 2번 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
tty5799 committed Sep 24, 2024
1 parent 990366e commit bc612d4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Header = () => {
<header class="bg-blue-600 text-white p-4 sticky top-0">
<h1 class="text-2xl font-bold">항해플러스</h1>
</header>
<nav class="bg-white shadow-md p-2 sticky top-14">
<nav id="header-nav" class="bg-white shadow-md p-2 sticky top-14">
<ul class="flex justify-around">
${isLogin ? `
<li><a href="/" class="${activeClass('/')}">홈</a></li>
Expand Down
27 changes: 20 additions & 7 deletions src/utils/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,25 @@ export default class Router {

addWholeAnchorEvent() {
const aTags = document.querySelectorAll('a');
aTags.forEach((tag) =>
tag.addEventListener('click', (e) => {
e.preventDefault();
const tagRef = tag.href.replace(location.origin, '');
this.render(tagRef);
})
);
const headerNav = document.getElementById('header-nav')

if(headerNav) {
document.querySelectorAll('li').forEach((tag) => {
tag.addEventListener('click', (event) => {
event.preventDefault();

const tagRef = tag.href.replace(location.origin, '');

Check failure on line 52 in src/utils/router.js

View workflow job for this annotation

GitHub Actions / advacned

Unhandled error

TypeError: Cannot read properties of undefined (reading 'replace') ❯ HTMLLIElement.<anonymous> src/utils/router.js:52:45 ❯ HTMLLIElement.callTheUserObjectsOperation node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30 ❯ innerInvokeEventListeners node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:350:25 ❯ invokeEventListeners node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:286:3 ❯ HTMLAnchorElementImpl._dispatch node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:233:9 ❯ fireAnEvent node_modules/jsdom/lib/jsdom/living/helpers/events.js:18:36 ❯ HTMLAnchorElementImpl.click node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:85:5 ❯ HTMLAnchorElement.click node_modules/jsdom/lib/jsdom/living/generated/HTMLElement.js:108:34 ❯ src/__tests__/advanced.test.js:24:38 ❯ node_modules/@vitest/runner/dist/index.js:146:14 This error originated in "src/__tests__/advanced.test.js" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "네비게이션의 링크를 클릭에서 이벤트 전파를 막았을 때, 아무일도 일어나지 않는다.". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.

Check failure on line 52 in src/utils/router.js

View workflow job for this annotation

GitHub Actions / basic

Unhandled error

TypeError: Cannot read properties of undefined (reading 'replace') ❯ HTMLLIElement.<anonymous> src/utils/router.js:52:45 ❯ HTMLLIElement.callTheUserObjectsOperation node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30 ❯ innerInvokeEventListeners node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:350:25 ❯ invokeEventListeners node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:286:3 ❯ HTMLAnchorElementImpl._dispatch node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:233:9 ❯ fireAnEvent node_modules/jsdom/lib/jsdom/living/helpers/events.js:18:36 ❯ HTMLAnchorElementImpl.click node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:85:5 ❯ HTMLAnchorElement.click node_modules/jsdom/lib/jsdom/living/generated/HTMLElement.js:108:34 ❯ src/__tests__/basic.test.js:69:20 ❯ node_modules/@vitest/runner/dist/index.js:529:5 This error originated in "src/__tests__/basic.test.js" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "로그인 폼에서 사용자 이름을 입력하고 제출하면 로그인 되고, 로그아웃 버튼 클릭시 로그아웃 된다.". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.

Check failure on line 52 in src/utils/router.js

View workflow job for this annotation

GitHub Actions / basic

Unhandled error

TypeError: Cannot read properties of undefined (reading 'replace') ❯ HTMLLIElement.<anonymous> src/utils/router.js:52:45 ❯ HTMLLIElement.callTheUserObjectsOperation node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30 ❯ innerInvokeEventListeners node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:350:25 ❯ invokeEventListeners node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:286:3 ❯ HTMLAnchorElementImpl._dispatch node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:233:9 ❯ fireAnEvent node_modules/jsdom/lib/jsdom/living/helpers/events.js:18:36 ❯ HTMLAnchorElementImpl.click node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:85:5 ❯ HTMLAnchorElement.click node_modules/jsdom/lib/jsdom/living/generated/HTMLElement.js:108:34 ❯ src/__tests__/basic.test.js:89:41 ❯ node_modules/@vitest/runner/dist/index.js:146:14 This error originated in "src/__tests__/basic.test.js" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "로그인한 사용자의 이름과 소개가 표시된다". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.

Check failure on line 52 in src/utils/router.js

View workflow job for this annotation

GitHub Actions / basic

Unhandled error

TypeError: Cannot read properties of undefined (reading 'replace') ❯ HTMLLIElement.<anonymous> src/utils/router.js:52:45 ❯ HTMLLIElement.callTheUserObjectsOperation node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30 ❯ innerInvokeEventListeners node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:350:25 ❯ invokeEventListeners node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:286:3 ❯ HTMLAnchorElementImpl._dispatch node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:233:9 ❯ fireAnEvent node_modules/jsdom/lib/jsdom/living/helpers/events.js:18:36 ❯ HTMLAnchorElementImpl.click node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:85:5 ❯ HTMLAnchorElement.click node_modules/jsdom/lib/jsdom/living/generated/HTMLElement.js:108:34 ❯ src/__tests__/basic.test.js:89:41 ❯ node_modules/@vitest/runner/dist/index.js:146:14 This error originated in "src/__tests__/basic.test.js" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "프로필 수정 기능이 동작한다". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.

Check failure on line 52 in src/utils/router.js

View workflow job for this annotation

GitHub Actions / basic

Unhandled error

TypeError: Cannot read properties of undefined (reading 'replace') ❯ HTMLLIElement.<anonymous> src/utils/router.js:52:45 ❯ HTMLLIElement.callTheUserObjectsOperation node_modules/jsdom/lib/jsdom/living/generated/EventListener.js:26:30 ❯ innerInvokeEventListeners node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:350:25 ❯ invokeEventListeners node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:286:3 ❯ HTMLAnchorElementImpl._dispatch node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:233:9 ❯ HTMLAnchorElementImpl.dispatchEvent node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:104:17 ❯ HTMLAnchorElement.dispatchEvent node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:241:34 ❯ node_modules/@testing-library/user-event/dist/esm/event/dispatchEvent.js:43:33 ❯ Object.eventWrapper node_modules/@testing-library/dom/dist/config.js:25:23 ❯ wrapEvent node_modules/@testing-library/user-event/dist/esm/event/wrapEvent.js:4:24 This error originated in "src/__tests__/basic.test.js" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "Header, Footer 컴포넌트가 메인 페이지와 프로필 페이지에 존재하고, 로그인페이지와 에러페이지에는 존재하지 않는다.". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
this.render(tagRef)
});
});
} else {
aTags.forEach((tag) => {
tag.addEventListener('click', (e) => {
e.preventDefault();
const tagRef = tag.href.replace(location.origin, '');
this.render(tagRef);
});
});
}
}
}

0 comments on commit bc612d4

Please sign in to comment.