33 أسطر
935 B
TypeScript
33 أسطر
935 B
TypeScript
import { LikesService } from './likes.service';
|
|
|
|
describe('LikesService', () => {
|
|
it('returns liked false from status when target post no longer exists', async () => {
|
|
const likesRepository = {
|
|
findOne: jest.fn(),
|
|
};
|
|
const postsRepository = {
|
|
findById: jest.fn().mockResolvedValue(null),
|
|
};
|
|
const commentsRepository = {
|
|
findById: jest.fn(),
|
|
};
|
|
|
|
const service = new LikesService(
|
|
likesRepository as any,
|
|
postsRepository as any,
|
|
commentsRepository as any,
|
|
{ bumpGlobalVersion: jest.fn() } as any,
|
|
{ createLikeNotification: jest.fn() } as any,
|
|
);
|
|
|
|
await expect(
|
|
service.getStatus('user-1', { targetId: '507f1f77bcf86cd799439011', targetType: 'post' }),
|
|
).resolves.toEqual({
|
|
liked: false,
|
|
targetId: '507f1f77bcf86cd799439011',
|
|
targetType: 'post',
|
|
});
|
|
expect(likesRepository.findOne).not.toHaveBeenCalled();
|
|
});
|
|
});
|