mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix: update unit tests
This commit is contained in:
@@ -68,7 +68,10 @@ describe('BlockRepository', () => {
|
||||
jest.spyOn(blockModel, 'findById');
|
||||
|
||||
const result = await blockRepository.findOneAndPopulate(hasNextBlocks.id);
|
||||
expect(blockModel.findById).toHaveBeenCalledWith(hasNextBlocks.id);
|
||||
expect(blockModel.findById).toHaveBeenCalledWith(
|
||||
hasNextBlocks.id,
|
||||
undefined,
|
||||
);
|
||||
expect(result).toEqualPayload({
|
||||
...blockFixtures.find(({ name }) => name === hasNextBlocks.name),
|
||||
category,
|
||||
@@ -92,7 +95,7 @@ describe('BlockRepository', () => {
|
||||
blockFixture.name === 'hasNextBlocks' ? [hasPreviousBlocks] : [],
|
||||
}));
|
||||
|
||||
expect(blockModel.find).toHaveBeenCalledWith({});
|
||||
expect(blockModel.find).toHaveBeenCalledWith({}, undefined);
|
||||
expect(result).toEqualPayload(blocksWithCategory);
|
||||
});
|
||||
|
||||
@@ -109,7 +112,7 @@ describe('BlockRepository', () => {
|
||||
blockFixture.name === 'hasNextBlocks' ? [hasPreviousBlocks] : [],
|
||||
}));
|
||||
|
||||
expect(blockModel.find).toHaveBeenCalledWith({});
|
||||
expect(blockModel.find).toHaveBeenCalledWith({}, undefined);
|
||||
expect(result).toEqualPayload(blocksWithCategory);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,8 +21,8 @@ import {
|
||||
rootMongooseTestModule,
|
||||
} from '@/utils/test/test';
|
||||
|
||||
import { LabelModel, Label } from '../schemas/label.schema';
|
||||
import { SubscriberModel, Subscriber } from '../schemas/subscriber.schema';
|
||||
import { Label, LabelModel } from '../schemas/label.schema';
|
||||
import { Subscriber, SubscriberModel } from '../schemas/subscriber.schema';
|
||||
|
||||
import { LabelRepository } from './label.repository';
|
||||
import { SubscriberRepository } from './subscriber.repository';
|
||||
@@ -62,7 +62,7 @@ describe('LabelRepository', () => {
|
||||
const label = await labelRepository.findOne({ name: 'TEST_TITLE_2' });
|
||||
const result = await labelRepository.findOneAndPopulate(label.id);
|
||||
|
||||
expect(labelModel.findById).toHaveBeenCalledWith(label.id);
|
||||
expect(labelModel.findById).toHaveBeenCalledWith(label.id, undefined);
|
||||
expect(result).toEqualPayload({
|
||||
...labelFixtures.find(({ name }) => name === label.name),
|
||||
users,
|
||||
@@ -79,7 +79,7 @@ describe('LabelRepository', () => {
|
||||
users,
|
||||
}));
|
||||
|
||||
expect(labelModel.find).toHaveBeenCalledWith({});
|
||||
expect(labelModel.find).toHaveBeenCalledWith({}, undefined);
|
||||
expect(result).toEqualPayload(labelsWithUsers);
|
||||
});
|
||||
});
|
||||
@@ -94,7 +94,7 @@ describe('LabelRepository', () => {
|
||||
users,
|
||||
}));
|
||||
|
||||
expect(labelModel.find).toHaveBeenCalledWith({});
|
||||
expect(labelModel.find).toHaveBeenCalledWith({}, undefined);
|
||||
expect(result).toEqualPayload(labelsWithUsers.sort(sortRowsBy));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
rootMongooseTestModule,
|
||||
} from '@/utils/test/test';
|
||||
|
||||
import { MessageModel, Message } from '../schemas/message.schema';
|
||||
import { Message, MessageModel } from '../schemas/message.schema';
|
||||
import { SubscriberModel } from '../schemas/subscriber.schema';
|
||||
import { AnyMessage } from '../schemas/types/message';
|
||||
|
||||
@@ -70,7 +70,7 @@ describe('MessageRepository', () => {
|
||||
const user = await userRepository.findOne(message['sentBy']);
|
||||
const result = await messageRepository.findOneAndPopulate(message.id);
|
||||
|
||||
expect(messageModel.findById).toHaveBeenCalledWith(message.id);
|
||||
expect(messageModel.findById).toHaveBeenCalledWith(message.id, undefined);
|
||||
expect(result).toEqualPayload({
|
||||
...messageFixtures.find(({ mid }) => mid === message.mid),
|
||||
sender,
|
||||
@@ -95,7 +95,7 @@ describe('MessageRepository', () => {
|
||||
sentBy: allUsers.find(({ id }) => id === message['sentBy']).id,
|
||||
}));
|
||||
|
||||
expect(messageModel.find).toHaveBeenCalledWith({});
|
||||
expect(messageModel.find).toHaveBeenCalledWith({}, undefined);
|
||||
expect(result).toEqualPayload(messages);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
import { AttachmentService } from '@/attachment/services/attachment.service';
|
||||
import { LoggerService } from '@/logger/logger.service';
|
||||
import { UserRepository } from '@/user/repositories/user.repository';
|
||||
import { UserModel, User } from '@/user/schemas/user.schema';
|
||||
import { User, UserModel } from '@/user/schemas/user.schema';
|
||||
import {
|
||||
installSubscriberFixtures,
|
||||
subscriberFixtures,
|
||||
@@ -31,11 +31,11 @@ import {
|
||||
rootMongooseTestModule,
|
||||
} from '@/utils/test/test';
|
||||
|
||||
import { LabelModel, Label } from '../schemas/label.schema';
|
||||
import { Label, LabelModel } from '../schemas/label.schema';
|
||||
import {
|
||||
SubscriberModel,
|
||||
Subscriber,
|
||||
SubscriberFull,
|
||||
SubscriberModel,
|
||||
} from '../schemas/subscriber.schema';
|
||||
|
||||
import { LabelRepository } from './label.repository';
|
||||
@@ -119,7 +119,10 @@ describe('SubscriberRepository', () => {
|
||||
assignedTo: allUsers.find(({ id }) => subscriber.assignedTo === id),
|
||||
};
|
||||
|
||||
expect(subscriberModel.findById).toHaveBeenCalledWith(subscriber.id);
|
||||
expect(subscriberModel.findById).toHaveBeenCalledWith(
|
||||
subscriber.id,
|
||||
undefined,
|
||||
);
|
||||
expect(result).toEqualPayload(subscriberWithLabels);
|
||||
});
|
||||
});
|
||||
@@ -133,7 +136,7 @@ describe('SubscriberRepository', () => {
|
||||
pageQuery,
|
||||
);
|
||||
|
||||
expect(subscriberModel.find).toHaveBeenCalledWith({});
|
||||
expect(subscriberModel.find).toHaveBeenCalledWith({}, undefined);
|
||||
expect(result).toEqualPayload(
|
||||
subscribersWithPopulatedFields.sort(sortRowsBy),
|
||||
);
|
||||
@@ -145,7 +148,7 @@ describe('SubscriberRepository', () => {
|
||||
jest.spyOn(subscriberModel, 'find');
|
||||
const result = await subscriberRepository.findAllAndPopulate();
|
||||
|
||||
expect(subscriberModel.find).toHaveBeenCalledWith({});
|
||||
expect(subscriberModel.find).toHaveBeenCalledWith({}, undefined);
|
||||
expect(result).toEqualPayload(
|
||||
subscribersWithPopulatedFields.sort(sortRowsBy),
|
||||
);
|
||||
|
||||
@@ -170,7 +170,10 @@ describe('BlockService', () => {
|
||||
jest.spyOn(blockRepository, 'findOneAndPopulate');
|
||||
const result = await blockService.findOneAndPopulate(block.id);
|
||||
|
||||
expect(blockRepository.findOneAndPopulate).toHaveBeenCalledWith(block.id);
|
||||
expect(blockRepository.findOneAndPopulate).toHaveBeenCalledWith(
|
||||
block.id,
|
||||
undefined,
|
||||
);
|
||||
expect(result).toEqualPayload({
|
||||
...blockFixtures.find(({ name }) => name === 'hasNextBlocks'),
|
||||
category,
|
||||
@@ -196,6 +199,7 @@ describe('BlockService', () => {
|
||||
expect(blockRepository.findAndPopulate).toHaveBeenCalledWith(
|
||||
{},
|
||||
undefined,
|
||||
undefined,
|
||||
);
|
||||
expect(result).toEqualPayload(blocksWithCategory);
|
||||
});
|
||||
|
||||
@@ -113,6 +113,7 @@ describe('MessageService', () => {
|
||||
|
||||
expect(messageRepository.findOneAndPopulate).toHaveBeenCalledWith(
|
||||
message.id,
|
||||
undefined,
|
||||
);
|
||||
expect(result).toEqualPayload({
|
||||
...messageFixtures.find(({ mid }) => mid === message.mid),
|
||||
|
||||
Reference in New Issue
Block a user