48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
import { chatService } from './chatService';
|
|
|
|
describe('chatService', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
describe('getChannels', () => {
|
|
it('should return channels', async () => {
|
|
const channels = await chatService.getChannels();
|
|
|
|
expect(channels).toBeDefined();
|
|
expect(Array.isArray(channels)).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('getDMs', () => {
|
|
it('should return direct messages', async () => {
|
|
const dms = await chatService.getDMs();
|
|
|
|
expect(dms).toBeDefined();
|
|
expect(Array.isArray(dms)).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('getMessages', () => {
|
|
it('should return messages for a channel', async () => {
|
|
const messages = await chatService.getMessages('channel-1');
|
|
|
|
expect(messages).toBeDefined();
|
|
expect(Array.isArray(messages)).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('sendMessage', () => {
|
|
it('should send a message successfully', async () => {
|
|
const result = await chatService.sendMessage('channel-1', {
|
|
content: 'Test message',
|
|
});
|
|
|
|
expect(result).toBeDefined();
|
|
expect(result).toHaveProperty('id');
|
|
expect(result).toHaveProperty('sender');
|
|
expect(result).toHaveProperty('content');
|
|
});
|
|
});
|
|
});
|