Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into develop
  • Loading branch information
hwinkr committed Dec 23, 2024
2 parents d9a6890 + 07bfecd commit bd6f208
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion backend/src/main/resources/security
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

0 comments on commit bd6f208

Please sign in to comment.