Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

test(sdk-js): pin both ends of the accepted idempotency key range

Yudhi Armyndharise793c7b4ecf3
diff --git a/sdk/javascript/test/messages.test.ts b/sdk/javascript/test/messages.test.ts
index 860f254d7..c34921055 100644
--- a/sdk/javascript/test/messages.test.ts
+++ b/sdk/javascript/test/messages.test.ts
@@ -71,7 +71,7 @@ describe('MessagesResource idempotency keys', () => {
expect(t.lastCall!.headers['idempotency-key']).toBe('default-key');
});
- it.each(['', 'has space', ' key', 'key ', 'key\n', 'key\t', 'caf\u00e9', 'x'.repeat(256)])(
+ it.each(['', 'has space', ' key', 'key ', 'key\n', 'key\t', 'caf\u00e9', 'a\u007fb', 'x'.repeat(256)])(
'rejects invalid key %j before transport',
async key => {
const t = new MockTransport().on('POST', /send-text$/, { body: { messageId: 'm', timestamp: 1 } });
@@ -81,7 +81,7 @@ describe('MessagesResource idempotency keys', () => {
},
);
- it.each(['!', 'x'.repeat(255)])('accepts visible ASCII key %j', async key => {
+ it.each(['!', '~', 'x', 'x'.repeat(255)])('accepts visible ASCII key %j', async key => {
const t = new MockTransport().on('POST', /send-text$/, { body: { messageId: 'm', timestamp: 1 } });
const c = new OpenWAClient({ baseUrl: 'http://localhost', apiKey: 'k', fetch: t.asFetch() });
await c.messages.sendText('s', { chatId: '[email protected]', text: 'hi' }, key);