feat: add url property to RequestInfo interface (#1353)
Co-authored-by: Matt <77928207+mattzcarey@users.noreply.github.com>
This commit is contained in:
parent
825e9ab803
commit
97ab379e45
2 changed files with 36 additions and 8 deletions
|
|
@ -19,10 +19,15 @@ const createMockResponse = () => {
|
|||
return res as unknown as Mocked<http.ServerResponse>;
|
||||
};
|
||||
|
||||
const createMockRequest = ({ headers = {}, body }: { headers?: Record<string, string>; body?: string } = {}) => {
|
||||
const createMockRequest = ({
|
||||
headers = {},
|
||||
body,
|
||||
url = '/messages'
|
||||
}: { headers?: Record<string, string>; body?: string; url?: string } = {}) => {
|
||||
const mockReq = {
|
||||
headers,
|
||||
body: body ? body : undefined,
|
||||
url,
|
||||
auth: {
|
||||
token: 'test-token'
|
||||
},
|
||||
|
|
@ -312,7 +317,8 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
|
|||
'user-agent': 'node',
|
||||
'accept-encoding': 'gzip, deflate',
|
||||
'content-length': '124'
|
||||
}
|
||||
},
|
||||
url: `http://127.0.0.1:${serverPort}/?sessionId=${sessionId}`
|
||||
})
|
||||
}
|
||||
]
|
||||
|
|
@ -387,7 +393,7 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
|
|||
id: 1
|
||||
});
|
||||
const mockReq = createMockRequest({
|
||||
headers: { 'content-type': 'application/json' },
|
||||
headers: { host: 'localhost', 'content-type': 'application/json' },
|
||||
body: validMessage
|
||||
});
|
||||
const mockRes = createMockResponse();
|
||||
|
|
@ -416,8 +422,10 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
|
|||
},
|
||||
requestInfo: {
|
||||
headers: {
|
||||
host: 'localhost',
|
||||
'content-type': 'application/json'
|
||||
}
|
||||
},
|
||||
url: new URL('http://localhost/messages')
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -443,7 +443,8 @@ describe.each(zodTestMatrix)('$zodVersionLabel', (entry: ZodMatrixEntry) => {
|
|||
'user-agent': expect.any(String),
|
||||
'accept-encoding': expect.any(String),
|
||||
'content-length': expect.any(String)
|
||||
}
|
||||
},
|
||||
url: baseUrl.toString()
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue