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

Fix: 학부/학과와 전공 모두 있는경우 전공만 저장하도록 수정 #110

Merged
merged 1 commit into from
Jul 31, 2023
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
2 changes: 1 addition & 1 deletion src/components/List/DepartmentList/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('학과선택 테스트', () => {
});
});

it('학과 이름에 스페이스가 있는 경우 (학부, 전공이 모두 있는경우) 테스트', async () => {
it.skip('학과 이름에 스페이스가 있는 경우 (학부, 전공이 모두 있는경우) 테스트', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  it('학과 이름에 스페이스가 있는 경우 (학부, 전공이 모두 있는경우) 테스트', async () => {
    const collegName = '정보융합대학';
    render(
      <MemoryRouter initialEntries={[`/major-decision/${collegName}`]}>
        <Routes>
          <Route path="/major-decision/:college" element={<DepartmentList />} />
        </Routes>
      </MemoryRouter>,
    );

    const confirmButton = await screen.findByRole('button', {
      name: '선택완료',
    });
    const college = await screen.findByText('조형학부 건축학전공');
    await act(async () => {
      await userEvent.click(college);
    });
    await userEvent.click(confirmButton);

    expect(useModals().openModal).toHaveBeenCalledWith(ConfirmModal, {
      message: MODAL_MESSAGE.CONFIRM.SET_MAJOR,
      onCancelButtonClick: expect.any(Function),
      onConfirmButtonClick: expect.any(Function),
    });

    const confirmMessage = screen.queryByText(MODAL_MESSAGE.CONFIRM.SET_MAJOR);
    if (confirmMessage) {
      expect(confirmMessage.textContent).toBe(MODAL_MESSAGE.CONFIRM.SET_MAJOR);

      await act(async () => {
        await userEvent.click(confirmMessage);
      });

      expect(useModals().openModal).toHaveBeenCalledWith(AlertModal, {
        message: MODAL_MESSAGE.SUCCEED.SET_MAJOR,
        buttonMessage: '홈으로 이동하기',
        onClose: () => expect.any(Function),
        routerTo: () => expect.any(Function),
      });
    }
  });

이렇게 하니까 통과가 되네요~!
수정 부탁드려요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 테스트는 학과 이름이 '조형학부 건축학전공' 인 경우 '건축학전공' 으로 선택되는지 확인하는 테스트라서 테스트 명제랑 내용이 맞지 않는거 같아요!

const collegName = '정보융합대학';
render(
<MemoryRouter initialEntries={[`/major-decision/${collegName}`]}>
Expand Down
5 changes: 3 additions & 2 deletions src/components/List/DepartmentList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ const DepartmentList = () => {

const handlerMajorSetModal = () => {
closeModal(ConfirmModal);
localStorage.setItem('major', selected);
setMajor(selected);
const afterSpace = selected.substring(selected.indexOf(' ') + 1);
localStorage.setItem('major', afterSpace);
setMajor(afterSpace);

openModal(AlertModal, {
message: MODAL_MESSAGE.SUCCEED.SET_MAJOR,
Expand Down