Open
Conversation
ccc4a7f to
3031a54
Compare
Creative-Lee
approved these changes
Sep 3, 2023
Collaborator
Creative-Lee
left a comment
There was a problem hiding this comment.
테스트 보충해 주신다고 고생 많으셨습니다!
코멘트 확인해 주시고 따로 답변주셔도 좋아요 ㅎㅎ
별개로 Approve는 바로 하겠습니다~ 반영해주시고 머지해주세요~ ㅎㅎ
| expect(formatOrdinals(1)).toBe('1st'); | ||
| }); | ||
|
|
||
| test('숫자 2은 1nd를 반환한다.', () => { |
| expect(formatOrdinals(2)).toBe('2nd'); | ||
| }); | ||
|
|
||
| test('숫자 3은 1rd를 반환한다.', () => { |
|
|
||
| jest.useFakeTimers(); | ||
|
|
||
| describe('useDebounceEffect 테스트. debounce 제한 딜레이를 0.5초로 둘 경우', () => { |
Collaborator
There was a problem hiding this comment.
debounce 제한 딜레이를 0.5초로 둘 경우 이 부분은 아래 테스트 명으로 들어가야 될 것 같아요!
| }); | ||
| }); | ||
|
|
||
| test('fetch가 실패했을 경우, isLoading 은 false, datas는 null, error은 mockError다.', async () => { |
|
|
||
| expect(result.current.isLoading).toBe(true); | ||
|
|
||
| waitFor(() => { |
Collaborator
There was a problem hiding this comment.
💬 여기는 await가 안붙고 아래 실패케이스에는 붙는데 어떤 차이인가요?
jariita
requested changes
Sep 5, 2023
Collaborator
jariita
left a comment
There was a problem hiding this comment.
useDebounceEffect 테스트의 경우 의도대로 동작하지 않는 것 같은데,
당장 해결할 수 있는 문제가 아니라면 조금 더 고민 후에 반영해도 좋을 것 같습니다.
테스트가 가장 어려운 부분인데 고생많으셨습니다
|
|
||
| describe('useDebounceEffect 테스트. debounce 제한 딜레이를 0.5초로 둘 경우', () => { | ||
| test('0.499초 지났을 때, 한 번도 실행되지 않는다.', () => { | ||
| const fn = jest.fn(); |
Collaborator
There was a problem hiding this comment.
여기도 useFetch 테스트와 마찬가지로 beforeEach를 활용하면 좋을 것 같아요!
|
|
||
| jest.useFakeTimers(); | ||
|
|
||
| describe('useDebounceEffect 테스트. debounce 제한 딜레이를 0.5초로 둘 경우', () => { |
Collaborator
There was a problem hiding this comment.
💬 아래 경우에도 통과하고 있는데, 테스트를 어떻게 짜야할지 고민해봐야 할 것 같아요
test('0.499초 지났을 때, 한 번도 실행되지 않는다.', () => {
const fn = jest.fn();
const { rerender } = renderHook(({ deps, delay }) => useDebounceEffect(fn, deps, delay), {
initialProps: { deps: 'dependency1', delay: 500 },
});
expect(fn).not.toBeCalled();
rerender({ deps: 'dependency2', delay: 5000 });
act(() => {
jest.advanceTimersByTime(4000);
});
rerender({ deps: 'dependency4', delay: 5000 });
// 0ms
expect(fn).not.toBeCalled();
act(() => {
jest.advanceTimersByTime(1000);
});
// 1000ms
// fn이 실행되지 않아야 하는데 실행됨
expect(fn).not.toBeCalled();
});
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝작업 내용
전역 유틸함수 테스트
전역 custom hook 테스트
💬리뷰 참고사항
useFetch와 useMutation은 실패했을 때와 성공했을 때를 나누어서 테스트하였습니다.
mocking이 필요한 테스트라 난이도가 있어서, 핵심적인 부분만 테스트했는데 더 필요한 부분이 있으면 커멘트 남겨주세요.
#️⃣연관된 이슈
close #353