mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
Merge pull request #510 from Hexastack/fix/label-strict-null-check
fix: label
This commit is contained in:
commit
0448cc5bc6
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
* Copyright © 2025 Hexastack. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
@ -82,10 +82,10 @@ describe('LabelController', () => {
|
|||||||
labelService = module.get<LabelService>(LabelService);
|
labelService = module.get<LabelService>(LabelService);
|
||||||
subscriberService = module.get<SubscriberService>(SubscriberService);
|
subscriberService = module.get<SubscriberService>(SubscriberService);
|
||||||
labelController = module.get<LabelController>(LabelController);
|
labelController = module.get<LabelController>(LabelController);
|
||||||
label = await labelService.findOne({ name: 'TEST_TITLE_1' });
|
label = (await labelService.findOne({ name: 'TEST_TITLE_1' })) as Label;
|
||||||
labelToDelete = await labelService.findOne({
|
labelToDelete = (await labelService.findOne({
|
||||||
name: 'TEST_TITLE_2',
|
name: 'TEST_TITLE_2',
|
||||||
});
|
})) as Label;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(jest.clearAllMocks);
|
afterEach(jest.clearAllMocks);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
* Copyright © 2025 Hexastack. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
@ -21,7 +21,7 @@ import {
|
|||||||
rootMongooseTestModule,
|
rootMongooseTestModule,
|
||||||
} from '@/utils/test/test';
|
} from '@/utils/test/test';
|
||||||
|
|
||||||
import { Label, LabelModel } from '../schemas/label.schema';
|
import { Label, LabelFull, LabelModel } from '../schemas/label.schema';
|
||||||
import { Subscriber, SubscriberModel } from '../schemas/subscriber.schema';
|
import { Subscriber, SubscriberModel } from '../schemas/subscriber.schema';
|
||||||
|
|
||||||
import { LabelRepository } from './label.repository';
|
import { LabelRepository } from './label.repository';
|
||||||
@ -59,8 +59,12 @@ describe('LabelRepository', () => {
|
|||||||
describe('findOneAndPopulate', () => {
|
describe('findOneAndPopulate', () => {
|
||||||
it('should find one label by id, and populate its users', async () => {
|
it('should find one label by id, and populate its users', async () => {
|
||||||
jest.spyOn(labelModel, 'findById');
|
jest.spyOn(labelModel, 'findById');
|
||||||
const label = await labelRepository.findOne({ name: 'TEST_TITLE_2' });
|
const label = (await labelRepository.findOne({
|
||||||
const result = await labelRepository.findOneAndPopulate(label.id);
|
name: 'TEST_TITLE_2',
|
||||||
|
})) as Label;
|
||||||
|
const result = (await labelRepository.findOneAndPopulate(
|
||||||
|
label.id,
|
||||||
|
)) as LabelFull;
|
||||||
|
|
||||||
expect(labelModel.findById).toHaveBeenCalledWith(label.id, undefined);
|
expect(labelModel.findById).toHaveBeenCalledWith(label.id, undefined);
|
||||||
expect(result).toEqualPayload({
|
expect(result).toEqualPayload({
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
* Copyright © 2025 Hexastack. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
@ -26,8 +26,8 @@ import {
|
|||||||
} from '@/utils/test/test';
|
} from '@/utils/test/test';
|
||||||
|
|
||||||
import { LabelRepository } from '../repositories/label.repository';
|
import { LabelRepository } from '../repositories/label.repository';
|
||||||
import { LabelModel, Label, LabelFull } from '../schemas/label.schema';
|
import { Label, LabelFull, LabelModel } from '../schemas/label.schema';
|
||||||
import { SubscriberModel, Subscriber } from '../schemas/subscriber.schema';
|
import { Subscriber, SubscriberModel } from '../schemas/subscriber.schema';
|
||||||
|
|
||||||
import { SubscriberRepository } from './../repositories/subscriber.repository';
|
import { SubscriberRepository } from './../repositories/subscriber.repository';
|
||||||
import { LabelService } from './label.service';
|
import { LabelService } from './label.service';
|
||||||
@ -101,7 +101,9 @@ describe('LabelService', () => {
|
|||||||
describe('findOneAndPopulate', () => {
|
describe('findOneAndPopulate', () => {
|
||||||
it('should find one label by id, and populate its corresponding users', async () => {
|
it('should find one label by id, and populate its corresponding users', async () => {
|
||||||
jest.spyOn(labelRepository, 'findOneAndPopulate');
|
jest.spyOn(labelRepository, 'findOneAndPopulate');
|
||||||
const label = await labelRepository.findOne({ name: 'TEST_TITLE_1' });
|
const label = (await labelRepository.findOne({
|
||||||
|
name: 'TEST_TITLE_1',
|
||||||
|
})) as Label;
|
||||||
const result = await labelService.findOneAndPopulate(label.id);
|
const result = await labelService.findOneAndPopulate(label.id);
|
||||||
|
|
||||||
expect(result).toEqualPayload({
|
expect(result).toEqualPayload({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user