-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fe,be/feature/#456 web rtc test code작성 #466
The head ref may contain hidden characters: "FE,BE/feature/#456-WebRTC-TestCode\uC791\uC131"
Changes from 5 commits
8d57495
2a4fdf1
32df273
c19e879
dbe3377
b2ee3d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
type User = { | ||
roomId: string; | ||
role: 'host' | 'guest'; | ||
}; | ||
type Room = { | ||
roomId: string; | ||
password: string; | ||
wrongRoomId: string; | ||
wrongPassword: string; | ||
}; | ||
export type SocketMock = { | ||
id: string; | ||
emit: jest.Mock; | ||
join: jest.Mock; | ||
to: jest.Mock; | ||
}; | ||
|
||
export const hostUserMock: User = { | ||
roomId: 'testRoomId', | ||
role: 'host', | ||
}; | ||
export const guestUserMock: User = { | ||
roomId: 'testRoomId', | ||
role: 'guest', | ||
}; | ||
export const roomMock: Room = { | ||
roomId: 'testRoomId', | ||
password: 'testPassword', | ||
wrongRoomId: 'wrongRoomId', | ||
wrongPassword: 'wrongPassword', | ||
}; | ||
|
||
export const toRoomEmitMock = jest.fn(); | ||
|
||
export const guestSocketMock: SocketMock = { | ||
id: 'testGuestSocketId', | ||
emit: jest.fn(), | ||
join: jest.fn(), | ||
to: jest.fn().mockImplementation(() => ({ emit: toRoomEmitMock })), | ||
}; | ||
|
||
export const hostSocketMock: SocketMock = { | ||
id: 'testHostSocketId', | ||
emit: jest.fn(), | ||
join: jest.fn(), | ||
to: jest.fn().mockImplementation(() => ({ emit: toRoomEmitMock })), | ||
}; | ||
|
||
export const loggerServiceMock = { debug: jest.fn(), info: jest.fn() }; | ||
|
||
export const createRoomMock = (users: string[]) => ({ | ||
[roomMock.roomId]: { | ||
users, | ||
password: roomMock.password, | ||
}, | ||
}); | ||
|
||
export const twoPeopleInsideRoomMock = () => | ||
createRoomMock([hostSocketMock.id, guestSocketMock.id]); | ||
export const onlyGuestInsideRoomMock = () => | ||
createRoomMock([guestSocketMock.id]); | ||
export const onlyHostInsideRoomMock = () => createRoomMock([hostSocketMock.id]); | ||
|
||
export const createUsersMock = (mock: Array<{ id: string; user: User }>) => | ||
mock.reduce((acc, { id, user }) => ({ ...acc, [id]: user }), {}); | ||
|
||
export const twoPeopleInsideUsersMock = () => | ||
createUsersMock([ | ||
{ id: hostSocketMock.id, user: hostUserMock }, | ||
{ id: guestSocketMock.id, user: guestUserMock }, | ||
]); | ||
export const onlyGuestInsideUsersMock = () => | ||
createUsersMock([{ id: guestSocketMock.id, user: guestUserMock }]); | ||
export const onlyHostInsideUsersMock = () => | ||
createUsersMock([{ id: hostSocketMock.id, user: hostUserMock }]); | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
"reflect-metadata": "^0.1.13", | ||
"rxjs": "^7.8.1", | ||
"socket.io": "^4.7.2", | ||
"socket.io-client": "^4.7.3", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 엇 그렇네 테스트 할때만 필요한거니까 저기 있을 필요는 없겠다 |
||
"uuid": "^9.0.1", | ||
"winston": "^3.11.0" | ||
}, | ||
|
@@ -41,7 +42,7 @@ | |
"@trivago/prettier-plugin-sort-imports": "^4.3.0", | ||
"@types/express": "^4.17.17", | ||
"@types/jest": "^29.5.2", | ||
"@types/node": "^20.3.1", | ||
"@types/node": "^20.10.7", | ||
"@types/supertest": "^2.0.12", | ||
"@types/uuid": "^9.0.7", | ||
"@typescript-eslint/eslint-plugin": "^6.0.0", | ||
|
@@ -74,6 +75,9 @@ | |
"**/*.(t|j)s" | ||
], | ||
"coverageDirectory": "../coverage", | ||
"testEnvironment": "node" | ||
"testEnvironment": "node", | ||
"moduleNameMapper": { | ||
"^src/(.*)$": "<rootDir>/$1" | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 오 mock을 별도의 파일로 분리하니까 좋은 것 같아 👍 mock 이 많으니까 이것도 용도에 따라 분리하는 건 어떨까? 예를 들어 user 관련은
user.mocks.ts
파일에 저장하는 식으로?✨ signal 서버에 다른 서비스가 추가될 수도 있으니까
eventsGatewayMocks.ts
를events
디렉토리 안에 넣는 게 어떨까??There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확실히 지금도 한눈에 파악이 안돼서 용도에 따라 분리하면 더 좋을것같아 추가해둘게!
이것도 좋은것같아!👍