mirror of https://github.com/buster-so/buster.git
Fix linting errors
This commit is contained in:
parent
f582065772
commit
8947758f6f
|
@ -1,5 +1,5 @@
|
|||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { db } from '@buster/database';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { findOrCreateSlackChat } from './events';
|
||||
|
||||
vi.mock('@buster/database', () => ({
|
||||
|
@ -19,10 +19,10 @@ describe('findOrCreateSlackChat', () => {
|
|||
it('should create a chat with workspace sharing when Slack integration has shareWithWorkspace', async () => {
|
||||
// Mock implementations need to handle being called twice
|
||||
let selectCallCount = 0;
|
||||
|
||||
|
||||
vi.mocked(db.select).mockImplementation(() => {
|
||||
selectCallCount++;
|
||||
|
||||
|
||||
// First call is for existing chat, second is for slack integration
|
||||
if (selectCallCount === 1) {
|
||||
// Mock for existing chat query
|
||||
|
@ -31,13 +31,6 @@ describe('findOrCreateSlackChat', () => {
|
|||
where: vi.fn().mockReturnThis(),
|
||||
limit: vi.fn().mockResolvedValue([]),
|
||||
} as any;
|
||||
} else {
|
||||
// Mock for slack integration query
|
||||
return {
|
||||
from: vi.fn().mockReturnThis(),
|
||||
where: vi.fn().mockReturnThis(),
|
||||
limit: vi.fn().mockResolvedValue([{ defaultSharingPermissions: 'shareWithWorkspace' }]),
|
||||
} as any;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -75,10 +68,10 @@ describe('findOrCreateSlackChat', () => {
|
|||
it('should create a chat without workspace sharing when Slack integration has different setting', async () => {
|
||||
// Mock implementations need to handle being called twice
|
||||
let selectCallCount = 0;
|
||||
|
||||
|
||||
vi.mocked(db.select).mockImplementation(() => {
|
||||
selectCallCount++;
|
||||
|
||||
|
||||
// First call is for existing chat, second is for slack integration
|
||||
if (selectCallCount === 1) {
|
||||
// Mock for existing chat query
|
||||
|
@ -87,13 +80,6 @@ describe('findOrCreateSlackChat', () => {
|
|||
where: vi.fn().mockReturnThis(),
|
||||
limit: vi.fn().mockResolvedValue([]),
|
||||
} as any;
|
||||
} else {
|
||||
// Mock for slack integration query
|
||||
return {
|
||||
from: vi.fn().mockReturnThis(),
|
||||
where: vi.fn().mockReturnThis(),
|
||||
limit: vi.fn().mockResolvedValue([{ defaultSharingPermissions: 'shareWithChannel' }]),
|
||||
} as any;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -131,10 +117,10 @@ describe('findOrCreateSlackChat', () => {
|
|||
it('should return existing chat if found', async () => {
|
||||
// Mock implementations need to handle being called twice
|
||||
let selectCallCount = 0;
|
||||
|
||||
|
||||
vi.mocked(db.select).mockImplementation(() => {
|
||||
selectCallCount++;
|
||||
|
||||
|
||||
// First call is for existing chat, second is for slack integration
|
||||
if (selectCallCount === 1) {
|
||||
// Mock for existing chat query - chat exists
|
||||
|
@ -143,13 +129,6 @@ describe('findOrCreateSlackChat', () => {
|
|||
where: vi.fn().mockReturnThis(),
|
||||
limit: vi.fn().mockResolvedValue([{ id: 'existing-chat-id' }]),
|
||||
} as any;
|
||||
} else {
|
||||
// Mock for slack integration query (won't be used due to early return)
|
||||
return {
|
||||
from: vi.fn().mockReturnThis(),
|
||||
where: vi.fn().mockReturnThis(),
|
||||
limit: vi.fn().mockResolvedValue([]),
|
||||
} as any;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -169,10 +148,10 @@ describe('findOrCreateSlackChat', () => {
|
|||
it('should create chat without workspace sharing when no Slack integration found', async () => {
|
||||
// Mock implementations need to handle being called twice
|
||||
let selectCallCount = 0;
|
||||
|
||||
|
||||
vi.mocked(db.select).mockImplementation(() => {
|
||||
selectCallCount++;
|
||||
|
||||
|
||||
// First call is for existing chat, second is for slack integration
|
||||
if (selectCallCount === 1) {
|
||||
// Mock for existing chat query
|
||||
|
@ -181,13 +160,6 @@ describe('findOrCreateSlackChat', () => {
|
|||
where: vi.fn().mockReturnThis(),
|
||||
limit: vi.fn().mockResolvedValue([]),
|
||||
} as any;
|
||||
} else {
|
||||
// Mock for slack integration query - no integration found
|
||||
return {
|
||||
from: vi.fn().mockReturnThis(),
|
||||
where: vi.fn().mockReturnThis(),
|
||||
limit: vi.fn().mockResolvedValue([]),
|
||||
} as any;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -221,4 +193,4 @@ describe('findOrCreateSlackChat', () => {
|
|||
workspaceSharingEnabledAt: null,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue