Files
InfiniteAPI/src/__tests__/proto-tojson-long.test.ts
T
João Lucas de Oliveira Lopes 9611a1a982 fix(WAProto): Handle string values in long fields during JSON serialization (#1991)
* feat: add patch-tojson functionality for improved proto serialization

* Remove patch-tojson functionality and its import from the main index file to streamline the codebase.

* refactor: simplify longToString and longToNumber functions for better readability and performance
2026-01-14 08:33:45 +02:00

32 lines
808 B
TypeScript

import '../index.js'
import { proto } from '../../WAProto/index.js'
describe('proto serialization', () => {
it('handles string values in long fields gracefully', () => {
const message = proto.WebMessageInfo.fromObject({
key: {
remoteJid: '123@s.whatsapp.net',
id: 'ABC123',
fromMe: false
},
messageTimestamp: 1,
message: {
imageMessage: {
fileLength: 42
}
}
})
const imageMessage = message.message?.imageMessage
if (!imageMessage) {
throw new Error('imageMessage missing in test setup')
}
;(imageMessage as unknown as { fileLength: unknown }).fileLength = '1234567890123456789'
expect(() => JSON.stringify(message)).not.toThrow()
const json = message.toJSON()
expect(json.message?.imageMessage?.fileLength).toBe('1234567890123456789')
})
})