Skip to content
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
3 changes: 3 additions & 0 deletions __mocks__/react-redux.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const useDispatch = jest.fn();

export const useSelector = jest.fn();
22 changes: 22 additions & 0 deletions fake-server/createFakeData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* eslint-disable no-plusplus */

module.exports = () => {
const data = { groups: [] };

for (let i = 0; i < 30; i++) {
const randomMonth = Math.floor((Math.random() * (11 - 1)) + 1);
const randomDay = Math.floor((Math.random() * (30 - 1)) + 1);

data.groups.push({
id: i,
moderatorId: `user${i}`,
title: `스터디를 소개합니다. ${i}`,
applyStartDate: `2020-${randomMonth}-${randomDay}`,
applyEndDate: '2020-12-3',
personnel: randomMonth,
contents: `우리는 이것저것 합니다.${i}`,
tags: ['JavaScript', 'React', 'Algorithm'],
});
}
return data;
};
Comment on lines +1 to +22

Choose a reason for hiding this comment

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

map이라는 더 명시적인 함수를 이용해서 표현해주면 좋을 것 같아요\

const range = (length) => Array.from({ length }, (, i) => i);
const randomMonth = () => Math.floor((Math.random() * (11 - 1)) + 1);
const randomDay = () => Math.floor((Math.random() * (30 - 1)) + 1);

module.exports = () => {
  const groups = range(30)
    .map((i) => {
      const month = randomMonth();
      const day = randomDay();

      return {
        id: i,
        moderatorId: `user${i}`,
        title: `스터디를 소개합니다. ${i}`,
        applyStartDate: `2020-${month}-${day}`,
        applyEndDate: '2020-12-3',
        personnel: month,
        contents: `우리는 이것저것 합니다.${i}`,
        tags: ['JavaScript', 'React', 'Algorithm'],
      }
    });

  return { groups };
}

155 changes: 155 additions & 0 deletions fake-server/db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"groups": [
{
"id": 1,
"moderatorId": "user1",
"title": "스터디를 소개합니다. 1",
"applyStartDate": "2020-7-10",
"applyEndDate": "2020-12-3",
"personnel": 7,
"contents": "우리는 이것저것 합니다.1",
"tags": [
"JavaScript",
"React",
"Algorithm"
]
},
{
"id": 2,
"moderatorId": "user2",
"title": "스터디를 소개합니다. 2",
"applyStartDate": "2020-10-18",
"applyEndDate": "2020-12-3",
"personnel": 10,
"contents": "우리는 이것저것 합니다.2",
"tags": [
"JavaScript",
"React",
"Algorithm"
]
},
{
"id": 3,
"moderatorId": "user3",
"title": "스터디를 소개합니다. 3",
"applyStartDate": "2020-2-18",
"applyEndDate": "2020-12-3",
"personnel": 2,
"contents": "우리는 이것저것 합니다.3",
"tags": [
"JavaScript",
"React",
"Algorithm"
]
},
{
"id": 4,
"moderatorId": "user4",
"title": "스터디를 소개합니다. 4",
"applyStartDate": "2020-8-14",
"applyEndDate": "2020-12-3",
"personnel": 8,
"contents": "우리는 이것저것 합니다.4",
"tags": [
"JavaScript",
"React",
"Algorithm"
]
},
{
"id": 5,
"moderatorId": "user5",
"title": "스터디를 소개합니다. 5",
"applyStartDate": "2020-4-2",
"applyEndDate": "2020-12-3",
"personnel": 4,
"contents": "우리는 이것저것 합니다.5",
"tags": [
"JavaScript",
"React",
"Algorithm"
]
},
{
"id": 6,
"moderatorId": "user6",
"title": "스터디를 소개합니다. 6",
"applyStartDate": "2020-9-25",
"applyEndDate": "2020-12-3",
"personnel": 9,
"contents": "우리는 이것저것 합니다.6",
"tags": [
"JavaScript",
"React",
"Algorithm"
]
},
{
"id": 7,
"moderatorId": "user7",
"title": "스터디를 소개합니다. 7",
"applyStartDate": "2020-8-20",
"applyEndDate": "2020-12-3",
"personnel": 8,
"contents": "우리는 이것저것 합니다.7",
"tags": [
"JavaScript",
"React",
"Algorithm"
]
},
{
"id": 8,
"moderatorId": "user8",
"title": "스터디를 소개합니다. 8",
"applyStartDate": "2020-8-25",
"applyEndDate": "2020-12-3",
"personnel": 8,
"contents": "우리는 이것저것 합니다.8",
"tags": [
"JavaScript",
"React",
"Algorithm"
]
},
{
"id": 9,
"moderatorId": "user9",
"title": "스터디를 소개합니다. 9",
"applyStartDate": "2020-2-11",
"applyEndDate": "2020-12-3",
"personnel": 2,
"contents": "우리는 이것저것 합니다.9",
"tags": [
"JavaScript",
"React",
"Algorithm"
]
},
{
"id": 10,
"moderatorId": "user10",
"title": "스터디를 소개합니다. 10",
"applyStartDate": "2020-3-2",
"applyEndDate": "2020-12-3",
"personnel": 3,
"contents": "우리는 이것저것 합니다.10",
"tags": [
"JavaScript",
"React",
"Algorithm"
]
}
],
"users": [
{
"id": 1,
"password": "1234",
"userId": "seung",
"groupId": 1
}
],
"profile": {
"name": "typicode"
}
}
28 changes: 28 additions & 0 deletions fixtures/study-groups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const studyGroups = [
{
id: 1,
moderatorId: 'user1',
title: '스터디를 소개합니다. 1',
personnel: 7,
contents: '우리는 이것저것 합니다.1',
tags: [
'JavaScript',
'React',
'Algorithm',
],
},
{
id: 2,
moderatorId: 'user2',
title: '스터디를 소개합니다. 2',
personnel: 10,
contents: '우리는 이것저것 합니다.2',
tags: [
'JavaScript',
'React',
'Algorithm',
],
},
];

export default studyGroups;
Loading