tests
This commit is contained in:
parent
3a7254708e
commit
b63e58784c
41 changed files with 5762 additions and 4477 deletions
|
|
@ -1,11 +1,16 @@
|
|||
import { beforeEach, describe, expect, it, mock, type Mock } from 'bun:test';
|
||||
import type { CacheProvider } from '@stock-bot/cache';
|
||||
import type { Logger } from '@stock-bot/logger';
|
||||
import type { Queue, QueueManager } from '@stock-bot/queue';
|
||||
import type { ExecutionContext, IServiceContainer, ServiceTypes } from '@stock-bot/types';
|
||||
import { BaseHandler } from '../src/base/BaseHandler';
|
||||
import { Handler, Operation, QueueSchedule, ScheduledOperation } from '../src/decorators/decorators';
|
||||
import {
|
||||
Handler,
|
||||
Operation,
|
||||
QueueSchedule,
|
||||
ScheduledOperation,
|
||||
} from '../src/decorators/decorators';
|
||||
import { createJobHandler } from '../src/utils/create-job-handler';
|
||||
import type { Logger } from '@stock-bot/logger';
|
||||
import type { QueueManager, Queue } from '@stock-bot/queue';
|
||||
import type { CacheProvider } from '@stock-bot/cache';
|
||||
|
||||
type MockLogger = {
|
||||
info: Mock<(message: string, meta?: any) => void>;
|
||||
|
|
@ -278,11 +283,13 @@ describe('createJobHandler', () => {
|
|||
it('should create a job handler', async () => {
|
||||
type TestPayload = { data: string };
|
||||
type TestResult = { success: boolean; payload: TestPayload };
|
||||
|
||||
const handlerFn = mock(async (payload: TestPayload): Promise<TestResult> => ({
|
||||
success: true,
|
||||
payload
|
||||
}));
|
||||
|
||||
const handlerFn = mock(
|
||||
async (payload: TestPayload): Promise<TestResult> => ({
|
||||
success: true,
|
||||
payload,
|
||||
})
|
||||
);
|
||||
const jobHandler = createJobHandler(handlerFn);
|
||||
|
||||
const result = await jobHandler({ data: 'test' });
|
||||
|
|
@ -299,4 +306,4 @@ describe('createJobHandler', () => {
|
|||
|
||||
await expect(jobHandler({})).rejects.toThrow('Handler error');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue