Skip to main content
Glama

Dodo Payments

Official
by dodopayments
form.test.ts1.9 kB
import { multipartFormRequestOptions, createForm } from 'dodopayments/internal/uploads'; import { toFile } from 'dodopayments/core/uploads'; describe('form data validation', () => { test('valid values do not error', async () => { await multipartFormRequestOptions( { body: { foo: 'foo', string: 1, bool: true, file: await toFile(Buffer.from('some-content')), blob: new Blob(['Some content'], { type: 'text/plain' }), }, }, fetch, ); }); test('null', async () => { await expect(() => multipartFormRequestOptions( { body: { null: null, }, }, fetch, ), ).rejects.toThrow(TypeError); }); test('undefined is stripped', async () => { const form = await createForm( { foo: undefined, bar: 'baz', }, fetch, ); expect(form.has('foo')).toBe(false); expect(form.get('bar')).toBe('baz'); }); test('nested undefined property is stripped', async () => { const form = await createForm( { bar: { baz: undefined, }, }, fetch, ); expect(Array.from(form.entries())).toEqual([]); const form2 = await createForm( { bar: { foo: 'string', baz: undefined, }, }, fetch, ); expect(Array.from(form2.entries())).toEqual([['bar[foo]', 'string']]); }); test('nested undefined array item is stripped', async () => { const form = await createForm( { bar: [undefined, undefined], }, fetch, ); expect(Array.from(form.entries())).toEqual([]); const form2 = await createForm( { bar: [undefined, 'foo'], }, fetch, ); expect(Array.from(form2.entries())).toEqual([['bar[]', 'foo']]); }); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dodopayments/dodopayments-node'

If you have feedback or need assistance with the MCP directory API, please join our Discord server