removed jest

This commit is contained in:
Bojan Kucera 2025-06-04 12:48:09 -04:00
parent fb22815450
commit 68592619f9
7 changed files with 242 additions and 203 deletions

View file

@ -45,7 +45,8 @@ beforeAll(() => {
return result;
}
}); // Mock QuestDB HTTP client
(global as any).fetch = jest.fn();
(global as any).fetch = () => {}; // Using Bun's built-in spyOn utilities
global.spyOn(global, 'fetch');
});
beforeEach(() => {
@ -63,7 +64,7 @@ beforeEach(() => {
}
} // Reset fetch mock
if ((global as any).fetch) {
((global as any).fetch as jest.Mock).mockClear();
((global as any).fetch as any).mockClear?.();
}
});
@ -85,7 +86,7 @@ export const questdbTestHelpers = {
/**
* Mock successful QuestDB HTTP response
*/ mockQuestDBHttpSuccess: (data: any) => {
((global as any).fetch as jest.Mock).mockResolvedValueOnce({
((global as any).fetch as any).mockResolvedValue?.({
ok: true,
status: 200,
json: async () => data,
@ -95,9 +96,8 @@ export const questdbTestHelpers = {
/**
* Mock QuestDB HTTP error
*/
mockQuestDBHttpError: (status: number, message: string) => {
((global as any).fetch as jest.Mock).mockResolvedValueOnce({
*/ mockQuestDBHttpError: (status: number, message: string) => {
((global as any).fetch as any).mockResolvedValue?.({
ok: false,
status,
json: async () => ({ error: message }),
@ -107,9 +107,8 @@ export const questdbTestHelpers = {
/**
* Mock InfluxDB line protocol response
*/
mockInfluxDBSuccess: () => {
((global as any).fetch as jest.Mock).mockResolvedValueOnce({
*/ mockInfluxDBSuccess: () => {
((global as any).fetch as any).mockResolvedValue?.({
ok: true,
status: 204,
text: async () => ''
@ -201,15 +200,21 @@ export const questdbTestHelpers = {
/**
* Mock connection pool
*/
createMockPool: () => ({
connect: jest.fn().mockResolvedValue({
query: jest.fn().mockResolvedValue({ rows: [], rowCount: 0 }),
release: jest.fn()
}),
end: jest.fn().mockResolvedValue(undefined),
totalCount: 0,
idleCount: 0,
waitingCount: 0
})
*/ createMockPool: () => {
const mockQuery = () => Promise.resolve({ rows: [], rowCount: 0 });
const mockRelease = () => {};
const mockConnect = () => Promise.resolve({
query: mockQuery,
release: mockRelease
});
const mockEnd = () => Promise.resolve(undefined);
return {
connect: mockConnect,
end: mockEnd,
totalCount: 0,
idleCount: 0,
waitingCount: 0
};
}
};