feat(api): handle Dakao registrations
This commit is contained in:
1 parent
404f7713b9
commit
3b2ac601a0
8 files changed
+2383
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import mongoose from 'mongoose';
|
||||
import { DakaoUserService } from '../dakao-user.service';
|
||||
import { PreferredPositionRegisterHandler } from './preferred-position-register.handler';
|
||||
|
||||
const objectId = (hex: string) => new mongoose.Types.ObjectId(hex);
|
||||
|
||||
describe('PreferredPositionRegisterHandler', () => {
|
||||
it('registers preferred positions for abbreviated joins', async () => {
|
||||
const registerPreferredPositions = jest.fn().mockResolvedValue({
|
||||
preferredPositions: [
|
||||
{ position: 'MID', priority: 1 },
|
||||
{ position: 'JGL', priority: 2 },
|
||||
],
|
||||
});
|
||||
const handler = new PreferredPositionRegisterHandler({
|
||||
registerPreferredPositions,
|
||||
} as unknown as DakaoUserService);
|
||||
|
||||
const segments = await handler.handle({
|
||||
communityId: objectId('111111111111111111111111'),
|
||||
senderUserId: 'kakao-user-1',
|
||||
senderNickname: '프리리',
|
||||
positions: ['MID', 'JGL'],
|
||||
});
|
||||
|
||||
expect(registerPreferredPositions).toHaveBeenCalledWith({
|
||||
communityId: objectId('111111111111111111111111'),
|
||||
kakaoTalkId: 'kakao-user-1',
|
||||
kakaoTalkNickname: '프리리',
|
||||
positions: ['MID', 'JGL'],
|
||||
});
|
||||
expect(segments[1]).toMatchObject({
|
||||
kind: 'text',
|
||||
text: expect.stringContaining('선호 포지션 등록 완료'),
|
||||
});
|
||||
expect(segments[1]).toMatchObject({
|
||||
kind: 'text',
|
||||
text: expect.stringContaining('!내전 신청 <내전코드>'),
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user