Code quality improvements and cleanup + Implemented ChatService
Some checks failed
Setup testing environment and test the code / build (push) Has been cancelled
Some checks failed
Setup testing environment and test the code / build (push) Has been cancelled
This commit is contained in:
24
src/services/chatService.test.ts
Normal file
24
src/services/chatService.test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import {describe, expect, it} from "vitest";
|
||||
import {ChatService} from "./chatService";
|
||||
import {DatabaseMock} from "../mocks/storage/database";
|
||||
import {faker} from "@faker-js/faker/locale/en";
|
||||
|
||||
describe("ChatService", () => {
|
||||
const service = new ChatService("", "", new DatabaseMock(), (action, data) => {})
|
||||
|
||||
it('should get chats', async () => {
|
||||
const chats = await service.get()
|
||||
expect(chats[0].userid).toBe("chatPartnerId")
|
||||
})
|
||||
|
||||
it('should get availability', async () => {
|
||||
const available = await service.getUserAvailability("")
|
||||
expect(available).toBeTruthy()
|
||||
});
|
||||
|
||||
it('should create a new chat', async () => {
|
||||
const chatPartnerName = faker.internet.displayName()
|
||||
const newChat = await service.startNew(chatPartnerName)
|
||||
expect(newChat.username).toBe(chatPartnerName)
|
||||
});
|
||||
})
|
||||
Reference in New Issue
Block a user