test: fix failing tests by adding mocks to bullmq
This commit is contained in:
parent
583a982930
commit
77dd73bdb4
4 changed files with 21 additions and 7 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -5,7 +5,7 @@ on:
|
|||
env:
|
||||
ROOT_FOLDER: /runtipi
|
||||
JWT_SECRET: 'secret'
|
||||
ROOT_FOLDER_HOST: /tipi
|
||||
ROOT_FOLDER_HOST: /runtipi
|
||||
APPS_REPO_ID: repo-id
|
||||
INTERNAL_IP: localhost
|
||||
REDIS_HOST: redis
|
||||
|
|
|
@ -22,7 +22,7 @@ describe('ResetPasswordContainer', () => {
|
|||
render(<ResetPasswordContainer isRequested={false} />);
|
||||
expect(screen.getByText('Reset your password')).toBeInTheDocument();
|
||||
expect(screen.getByText('Run this command on your server and then refresh this page')).toBeInTheDocument();
|
||||
expect(screen.getByText('./scripts/reset-password.sh')).toBeInTheDocument();
|
||||
expect(screen.getByText('./runtipi-cli reset-password')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render the password reset success message', async () => {
|
||||
|
|
|
@ -24,11 +24,13 @@ class EventDispatcher {
|
|||
public async cleanRepeatableJobs() {
|
||||
const repeatableJobs = await this.queue.getRepeatableJobs();
|
||||
|
||||
await Promise.all(
|
||||
repeatableJobs.map(async (job) => {
|
||||
await this.queue.removeRepeatableByKey(job.key);
|
||||
}),
|
||||
);
|
||||
if (repeatableJobs) {
|
||||
await Promise.all(
|
||||
repeatableJobs.map(async (job) => {
|
||||
await this.queue.removeRepeatableByKey(job.key);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static getInstance(): EventDispatcher {
|
||||
|
|
|
@ -13,6 +13,18 @@ jest.mock('vitest', () => ({
|
|||
vi: jest,
|
||||
}));
|
||||
|
||||
jest.mock('bullmq', () => ({
|
||||
Queue: jest.fn().mockImplementation(() => ({
|
||||
add: jest.fn(),
|
||||
getRepeatableJobs: jest.fn().mockResolvedValue([]),
|
||||
removeRepeatableByKey: jest.fn(),
|
||||
obliterate: jest.fn(),
|
||||
})),
|
||||
QueueEvents: jest.fn().mockImplementation(() => ({
|
||||
on: jest.fn(),
|
||||
})),
|
||||
}));
|
||||
|
||||
console.error = jest.fn();
|
||||
|
||||
beforeEach(async () => {
|
||||
|
|
Loading…
Reference in a new issue