Skip to content

Commit 3c65c0c

Browse files
committed
test(upload): deduplicate createRequestBodyForJson tests
Remove duplicate createRequestBodyForJson tests from socket-sdk-upload.test.mts since more comprehensive tests already exist in test/unit/utils.test.mts. Removed duplicate tests (4 tests): - should create FormData for JSON data with default basename - should create FormData for JSON with custom basename - should handle basename with different extension - should handle complex JSON objects Test reduction: - socket-sdk-upload.test.mts: 19 tests → 15 tests (-4 duplicate tests) - utils.test.mts retains comprehensive coverage with additional edge cases Coverage verification: - Overall coverage maintained at 81.19% (no change) - All tests still pass (551 total tests → 547 tests) - No loss of coverage for createRequestBodyForJson function Added note in socket-sdk-upload.test.mts to prevent future duplication.
1 parent 8b433fd commit 3c65c0c

File tree

1 file changed

+2
-47
lines changed

1 file changed

+2
-47
lines changed

test/unit/socket-sdk-upload.test.mts

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -127,53 +127,8 @@ describe('File Upload - createRequestBodyForFilepaths', () => {
127127
})
128128
})
129129

130-
describe('File Upload - createRequestBodyForJson', () => {
131-
it('should create FormData for JSON data with default basename', () => {
132-
const jsonData = { name: 'test', version: '1.0.0' }
133-
134-
const result = createRequestBodyForJson(jsonData)
135-
136-
expect(result).toBeInstanceOf(FormData)
137-
expect(result.getHeaders()).toHaveProperty('content-type')
138-
expect(result.getHeaders()['content-type']).toMatch(
139-
/^multipart\/form-data; boundary=/,
140-
)
141-
})
142-
143-
it('should create FormData for JSON with custom basename', () => {
144-
const jsonData = { foo: 'bar' }
145-
const basename = 'custom.json'
146-
147-
const result = createRequestBodyForJson(jsonData, basename)
148-
149-
expect(result).toBeInstanceOf(FormData)
150-
expect(result.getBoundary()).toBeTruthy()
151-
})
152-
153-
it('should handle basename with different extension', () => {
154-
const jsonData = { test: true }
155-
const basename = 'metadata.txt'
156-
157-
const result = createRequestBodyForJson(jsonData, basename)
158-
159-
expect(result).toBeInstanceOf(FormData)
160-
expect(result.getBoundary()).toBeTruthy()
161-
})
162-
163-
it('should handle complex JSON objects', () => {
164-
const jsonData = {
165-
nested: { deeply: { value: 123 } },
166-
array: [1, 2, 3],
167-
boolean: true,
168-
null: null,
169-
}
170-
171-
const result = createRequestBodyForJson(jsonData)
172-
173-
expect(result).toBeInstanceOf(FormData)
174-
expect(result.getBoundary()).toBeTruthy()
175-
})
176-
})
130+
// Note: createRequestBodyForJson tests are in test/unit/utils.test.mts
131+
// to avoid duplication with more comprehensive test coverage there.
177132

178133
describe('File Upload - createUploadRequest', () => {
179134
let tempDir: string

0 commit comments

Comments
 (0)