Skip to content

Commit 904c5f3

Browse files
committed
test: fix TypeScript errors in test files
- Remove unused IncomingMessage import from http-client-network-errors - Add proper type assertions for SocketSdkGenericResult in error branch tests - Ensures all test files pass TypeScript strict checks
1 parent ed8f0ee commit 904c5f3

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

test/unit/http-client-network-errors.test.mts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
66

77
import { createGetRequest, getResponse } from '../../src/http-client'
88

9-
import type { ClientRequest, IncomingMessage } from 'node:http'
9+
import type { ClientRequest } from 'node:http'
1010

1111
describe('HTTP Client - Network Error Handling', () => {
1212
beforeEach(() => {
@@ -56,7 +56,9 @@ describe('HTTP Client - Network Error Handling', () => {
5656
Object.assign(error, { code: 'ECONNRESET' })
5757
mockRequest.emit('error', error)
5858

59-
await expect(responsePromise).rejects.toThrow('Connection reset by server')
59+
await expect(responsePromise).rejects.toThrow(
60+
'Connection reset by server',
61+
)
6062
await expect(responsePromise).rejects.toThrow(
6163
'Possible network interruption',
6264
)

test/unit/socket-sdk-error-branches.test.mts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,28 +86,28 @@ describe('SocketSdk - Error Branch Coverage', () => {
8686
new SocketSdk('test-token', { baseUrl: getBaseUrl(), retries: 0 })
8787

8888
it('should handle sendApi with POST method', async () => {
89-
const result = await getClient().sendApi('/test-endpoint', {
89+
const result = (await getClient().sendApi('/test-endpoint', {
9090
body: { test: 'data' },
9191
method: 'POST',
92-
})
92+
})) as SocketSdkGenericResult<unknown>
9393

9494
expect(result.success).toBe(true)
9595
})
9696

9797
it('should handle sendApi with PUT method', async () => {
98-
const result = await getClient().sendApi('/test-endpoint', {
98+
const result = (await getClient().sendApi('/test-endpoint', {
9999
body: { test: 'data' },
100100
method: 'PUT',
101-
})
101+
})) as SocketSdkGenericResult<unknown>
102102

103103
expect(result.success).toBe(true)
104104
})
105105

106106
it('should handle sendApi with empty body', async () => {
107-
const result = await getClient().sendApi('/test-endpoint', {
107+
const result = (await getClient().sendApi('/test-endpoint', {
108108
body: {},
109109
method: 'POST',
110-
})
110+
})) as SocketSdkGenericResult<unknown>
111111

112112
expect(result.success).toBe(true)
113113
})

0 commit comments

Comments
 (0)