mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 02:51:24 +00:00
refactor(core): dedupe shared config and runtime helpers
This commit is contained in:
25
src/test-utils/mock-http-response.ts
Normal file
25
src/test-utils/mock-http-response.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { ServerResponse } from "node:http";
|
||||
|
||||
export function createMockServerResponse(): ServerResponse & { body?: string } {
|
||||
const headers: Record<string, string> = {};
|
||||
const res: {
|
||||
headersSent: boolean;
|
||||
statusCode: number;
|
||||
body?: string;
|
||||
setHeader: (key: string, value: string) => unknown;
|
||||
end: (body?: string) => unknown;
|
||||
} = {
|
||||
headersSent: false,
|
||||
statusCode: 200,
|
||||
setHeader: (key: string, value: string) => {
|
||||
headers[key.toLowerCase()] = value;
|
||||
return res;
|
||||
},
|
||||
end: (body?: string) => {
|
||||
res.headersSent = true;
|
||||
res.body = body;
|
||||
return res;
|
||||
},
|
||||
};
|
||||
return res as unknown as ServerResponse & { body?: string };
|
||||
}
|
||||
Reference in New Issue
Block a user