Skip to main content
Glama
resolveObjectPromises.test.ts2.09 kB
import { describe, expect, it } from 'vitest'; import { resolveObjectPromises } from './resolveObjectPromises'; const delay = async (ms: number) => { await new Promise((resolve) => setTimeout(resolve, ms)); }; const testCase = { test1: 1, test2: () => 2, test3: async () => 3, test4: [ 41, () => 42, async () => { await delay(100); return 43; }, [ Promise.resolve(44), async () => { await delay(100); return 45; }, 46, ], ], test5: { test51: () => 51, test52: () => 52, test53: () => 53, }, test6: { test61: { test611: 611, test612: 612, test613: 613, }, }, test7: { test71: async () => { await delay(100); return { test711: async () => 711, test712: async () => { await delay(100); return 712; }, test713: async () => { await delay(100); return [ 7131, async () => { await delay(100); return 7132; }, async () => { await delay(100); return 7133; }, 7134, ]; }, test714: 714, }; }, }, test8: 8, }; const testCaseResolved = { test1: 1, test2: 2, test3: 3, test4: [41, 42, 43, [44, 45, 46]], test5: { test51: 51, test52: 52, test53: 53, }, test6: { test61: { test611: 611, test612: 612, test613: 613, }, }, test7: { test71: { test711: 711, test712: 712, test713: [7131, 7132, 7133, 7134], test714: 714, }, }, test8: 8, }; describe('resolveObjectPromises', () => { it('should the result be in the same order as the original object', async () => { const resolved = await resolveObjectPromises<typeof testCase>(testCase); // Stringify the objects to ensure the order of the keys is the same expect(JSON.stringify(resolved)).toStrictEqual( JSON.stringify(testCaseResolved) ); }); });

Latest Blog Posts

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/aymericzip/intlayer'

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