Skip to content

Commit

Permalink
refactor: mock api 적용
Browse files Browse the repository at this point in the history
변경된 인터페이스를 msw handler에 적용 후 메인 컨텐츠, 작가페이지에서 무한 스크롤링 작동 테스트

ref #56
  • Loading branch information
ppark2ya committed Feb 15, 2022
1 parent b436fb6 commit fcdd64c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
12 changes: 8 additions & 4 deletions mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ export const handlers = [
msg: 'success!',
data: {
main_contents_list: contents,
is_last: false,
start,
paging: {
is_last: false,
start,
},
},
}),
);
Expand All @@ -48,8 +50,10 @@ export const handlers = [
msg: 'success!',
data: {
main_writer_list: writers,
is_last: false,
start,
paging: {
is_last: false,
start,
},
},
}),
);
Expand Down
4 changes: 3 additions & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ const Main: NextPage = function () {
useInfinityContents(searchParams, {
getNextPageParam: (lastPage) => {
const {
data: { isLast, start },
data: {
paging: { isLast, start },
},
} = lastPage;

return !isLast ? start + DEFAULT_SEARCH_RANGE : false;
Expand Down
4 changes: 3 additions & 1 deletion pages/writers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ const Main: NextPage = function () {
useInfinityWriters(searchParams, {
getNextPageParam: (lastPage) => {
const {
data: { isLast, start },
data: {
paging: { isLast, start },
},
} = lastPage;

return !isLast ? start + DEFAULT_SEARCH_RANGE : false;
Expand Down

0 comments on commit fcdd64c

Please sign in to comment.