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
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ describe('MQTT notification contract', () => {
const invite = {
id: 'invite-1',
matchType: MatchType.RANDOM,
gameType: 1,
status: InviteStatus.QUEUED,
ownerPlayerId: 'player-1',
players: [{ playerId: 'player-1', name: 'Player 1', avatar: null }],
Expand All @@ -81,6 +82,7 @@ describe('MQTT notification contract', () => {
const match = {
id: 'match-1',
matchType: MatchType.RANDOM,
gameType: 1,
status: MatchStatus.ACTIVE,
teamSize: 2 as const,
teams: [
Expand Down Expand Up @@ -110,6 +112,7 @@ describe('MQTT notification contract', () => {
{
id: invite.id,
matchType: invite.matchType,
gameType: invite.gameType,
status: invite.status,
ownerPlayer: { playerId: 'player-1', name: 'Player 1', avatar: null },
senderPlayer: { playerId: 'player-1', name: 'Player 1', avatar: null },
Expand Down
42 changes: 28 additions & 14 deletions src/__tests__/dailyTasks/formAnInnerConnection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ describe('FORM_AN_INNER_CONNECTION Daily Task', () => {
},
{
provide: DailyTaskProgressService,
useValue: { handleProgress: jest.fn().mockResolvedValue([true, null]) },
useValue: {
handleProgress: jest.fn().mockResolvedValue([true, null]),
},
},
],
}).compile();
Expand Down Expand Up @@ -114,8 +116,12 @@ describe('FORM_AN_INNER_CONNECTION Daily Task', () => {
type: ServerTaskName.FORM_AN_INNER_CONNECTION,
};

jest.spyOn(service['basicService'], 'readOne').mockResolvedValue([mockTask as any, null]);
jest.spyOn(service['basicService'], 'updateOne').mockResolvedValue([true, null]);
jest
.spyOn(service['basicService'], 'readOne')
.mockResolvedValue([mockTask as any, null]);
jest
.spyOn(service['basicService'], 'updateOne')
.mockResolvedValue([true, null]);

const [res, err] = await service.handleDailyTaskEvent({
playerId: 'player-1',
Expand All @@ -141,7 +147,9 @@ describe('FORM_AN_INNER_CONNECTION Daily Task', () => {
type: ServerTaskName.FORM_AN_INNER_CONNECTION,
};

jest.spyOn(service['basicService'], 'readOne').mockResolvedValue([mockTask as any, null]);
jest
.spyOn(service['basicService'], 'readOne')
.mockResolvedValue([mockTask as any, null]);
jest.spyOn(service, 'deleteTask').mockResolvedValue([true as any, null]);

const [res, err] = await service.handleDailyTaskEvent({
Expand All @@ -166,10 +174,12 @@ describe('FORM_AN_INNER_CONNECTION Daily Task', () => {
});

it('returns error when task is not found or owned by another clan', async () => {
jest.spyOn(service['basicService'], 'readOne').mockResolvedValue([
null,
[{ reason: 'NOT_FOUND', message: 'Task not found' }] as any,
]);
jest
.spyOn(service['basicService'], 'readOne')
.mockResolvedValue([
null,
[{ reason: 'NOT_FOUND', message: 'Task not found' }] as any,
]);

const [res, err] = await service.handleDailyTaskEvent({
playerId: 'player-1',
Expand All @@ -194,11 +204,15 @@ describe('FORM_AN_INNER_CONNECTION Daily Task', () => {
type: ServerTaskName.FORM_AN_INNER_CONNECTION,
};

jest.spyOn(service['basicService'], 'readOne').mockResolvedValue([mockTask as any, null]);
jest.spyOn(service['basicService'], 'updateOne').mockResolvedValue([
null,
[{ reason: 'DATABASE_ERROR', message: 'Write failed' }] as any,
]);
jest
.spyOn(service['basicService'], 'readOne')
.mockResolvedValue([mockTask as any, null]);
jest
.spyOn(service['basicService'], 'updateOne')
.mockResolvedValue([
null,
[{ reason: 'DATABASE_ERROR', message: 'Write failed' }] as any,
]);

const [res, err] = await service.handleDailyTaskEvent({
playerId: 'player-1',
Expand All @@ -212,4 +226,4 @@ describe('FORM_AN_INNER_CONNECTION Daily Task', () => {
expect(err).toBeDefined();
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('MatchmakingNotifier notifications', () => {
const room: MatchmakingRoomDto = {
id: 'invite-1',
matchType: MatchType.RANDOM,
gameType: 1,
status: InviteStatus.QUEUED,
ownerPlayerId: 'player-1',
players: [{ playerId: 'player-1', name: 'Player 1', avatar: null }],
Expand All @@ -40,6 +41,7 @@ describe('MatchmakingNotifier notifications', () => {
const match: MatchmakingMqttMatchDto = {
id: 'match-1',
matchType: MatchType.RANDOM,
gameType: 1,
status: MatchStatus.ACTIVE,
teamSize: 2,
teams: [
Expand All @@ -60,6 +62,7 @@ describe('MatchmakingNotifier notifications', () => {
const roomInvite: MatchmakingRoomInviteDto = {
id: 'invite-1',
matchType: MatchType.RANDOM,
gameType: 1,
status: InviteStatus.OPEN,
ownerPlayer: { playerId: 'player-1', name: 'Player 1', avatar: null },
senderPlayer: { playerId: 'player-1', name: 'Player 1', avatar: null },
Expand Down
Loading
Loading