mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(api): resolve lifecycle hook unit tests issue
This commit is contained in:
parent
1c782619d0
commit
99b0d88a82
@ -10,6 +10,8 @@ import { ModelDefinition } from '@nestjs/mongoose';
|
|||||||
|
|
||||||
import { LifecycleHookManager } from './lifecycle-hook-manager';
|
import { LifecycleHookManager } from './lifecycle-hook-manager';
|
||||||
|
|
||||||
|
afterEach(jest.clearAllMocks);
|
||||||
|
|
||||||
describe('LifecycleHookManager', () => {
|
describe('LifecycleHookManager', () => {
|
||||||
let modelMock: ModelDefinition;
|
let modelMock: ModelDefinition;
|
||||||
|
|
||||||
@ -42,8 +44,10 @@ describe('LifecycleHookManager', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should return hooks attached to a specific model', () => {
|
it('should return hooks attached to a specific model', () => {
|
||||||
// Attach hooks to mock model
|
if (!LifecycleHookManager.getModel(modelMock.name)) {
|
||||||
LifecycleHookManager.attach(modelMock);
|
// Attach hooks to mock model
|
||||||
|
LifecycleHookManager.attach(modelMock);
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve hooks
|
// Retrieve hooks
|
||||||
const hooks = LifecycleHookManager.getHooks('TestModel');
|
const hooks = LifecycleHookManager.getHooks('TestModel');
|
||||||
|
Loading…
Reference in New Issue
Block a user