Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] 약속 공유 링크 상수 경로 수정 #434

Merged
merged 4 commits into from
Dec 6, 2024
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
18 changes: 10 additions & 8 deletions frontend/src/hooks/useCalendar/useCalendar.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { act } from 'react';
import { act } from '@testing-library/react';

import renderHookWithProvider from '@hooks/__test__/renderHookWithProvider';

Expand Down Expand Up @@ -191,18 +191,20 @@ describe('useCalendar', () => {
const TEST_DATE = 4;

beforeEach(() => {
jest.setSystemTime(new Date(TEST_YEAR + 1, TEST_MONTH, TEST_DATE));
jest.setSystemTime(new Date(TEST_YEAR, TEST_MONTH, TEST_DATE));
});

it('현재 월 기준, 약속 날짜 범위가 1년을 벗어나면 토스트 UI를 활용하여 사용자에게 예외 피드백을 전달한다', () => {
it('현재 월 기준, 약속 날짜 범위가 1년을 벗어나면 토스트 UI를 활용하여 사용자에게 예외 피드백을 전달한다', async () => {
const { result } = renderHookWithProvider(useCalendar);

const { view } = result.current;
const { moveToNextMonth } = view;
act(() => {
moveToNextMonth();
});
// 1년이 12달이므로 moveToNextMonth() 함수를 13반 호출하면 범위를 초과합니다.
for (let i = 0; i < 13; i++) {
await act(async () => {
result.current.view.moveToNextMonth();
});
}

// 1년의 범위가 초과되었을 때, 토스트 메시지가 정상적으로 출력되는지 확인합니다.
expect(mockAddToast).toHaveBeenCalledWith({
message: TOAST_MESSAGES.OUT_OF_ONE_YEAR_RANGE,
type: 'warning',
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/hooks/useCalendar/useCalendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ interface useCalendarReturn {
isCurrentMonth: boolean;
}

const TODAY = new Date();
const ONE_YEAR_LATER = getFullDate(new Date(getYear(TODAY) + 1, getMonth(TODAY)));

type MonthDelta = -1 | 1;

const useCalendar = (): useCalendarReturn => {
const TODAY = new Date();
const ONE_YEAR_LATER = getFullDate(new Date(getYear(TODAY) + 1, getMonth(TODAY)));

const [currentFullDate, setCurrentFullDate] = useState(new Date());
const { addToast } = useToast();

Expand All @@ -51,7 +51,7 @@ const useCalendar = (): useCalendarReturn => {
const moveToNextMonth = () => {
const fullDate = getFullDate(currentFullDate);

if (fullDate >= ONE_YEAR_LATER) {
if (new Date(fullDate).getTime() >= new Date(ONE_YEAR_LATER).getTime()) {
addToast({
message: TOAST_MESSAGES.OUT_OF_ONE_YEAR_RANGE,
type: 'warning',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/MeetingLinkSharePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function MeetingLinkSharePage() {
state: { meetingInfo },
} = useLocation() as RouteState;

const LINK = `${window.location.protocol}/${window.location.host}/meeting/${uuid}`;
const LINK = `${window.location.origin}/meeting/${uuid}`;

const { handleKakaoTalkShare } = useKakaoTalkShare();

Expand Down
Loading