Finished implementing FileUploadService + added test workflow
This commit is contained in:
33
tests/fileUploadService.test.ts
Normal file
33
tests/fileUploadService.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import {describe, it} from "vitest";
|
||||
import {FileUploadService} from "../src/services/fileUploadService";
|
||||
import {environment, SDKConfig} from "../src/core/environment";
|
||||
import {getClient} from "../src/core/http";
|
||||
import {FileData} from "../src/domain/fileUploadService.schema";
|
||||
import axios from "axios";
|
||||
|
||||
describe("FileUploadService Integration Testing", () => {
|
||||
const FILE_UPL_SERVICE_TESTING_USER_ID = "000000000000000000000000"
|
||||
const FILE_UPL_SERVICE_TESTING_CHAT_ID = "000000000000000000000000"
|
||||
const FILE_UPL_SERVICE_TESTING_TOKEN = "testingToken"
|
||||
|
||||
environment.overwrite(<SDKConfig>{apiUrl: "http://localhost:3000", cdnUrl: "http://localhost:4000"})
|
||||
it('should upload all files', async () => {
|
||||
const response = await axios.get("https://picsum.photos/500", {
|
||||
responseType: 'blob'
|
||||
});
|
||||
|
||||
const service = new FileUploadService(FILE_UPL_SERVICE_TESTING_TOKEN, getClient(false), getClient(true));
|
||||
await service.uploadFiles(
|
||||
FILE_UPL_SERVICE_TESTING_CHAT_ID,
|
||||
FILE_UPL_SERVICE_TESTING_USER_ID,
|
||||
[
|
||||
{
|
||||
name: "filename",
|
||||
type: "image",
|
||||
extension: "jpeg",
|
||||
data: new File([response.data], "filename", { type: "image/jpeg" })
|
||||
}
|
||||
]
|
||||
)
|
||||
});
|
||||
})
|
||||
Reference in New Issue
Block a user