Skip to main content
Glama
promise.test.js1.58 kB
'use strict' const { test } = require('node:test') const { kTestInternals } = require('../../lib/symbols') const PonyPromise = require('../../lib/promise') test('withResolvers', async (t) => { t.plan(3) await t.test('resolve', async (t) => { t.plan(1) const { promise, resolve } = PonyPromise.withResolvers() resolve(true) t.assert.ok(await promise) }) await t.test('reject', async (t) => { t.plan(1) const { promise, reject } = PonyPromise.withResolvers() await t.assert.rejects(async () => { reject(Error('reject')) return promise }, { name: 'Error', message: 'reject' }) }) await t.test('thenable', async (t) => { t.plan(1) const { promise, resolve } = PonyPromise.withResolvers() resolve(true) promise.then((value) => { t.assert.ok(value) }) }) }) test('withResolvers - ponyfill', async (t) => { await t.test('resolve', async (t) => { t.plan(1) const { promise, resolve } = PonyPromise[kTestInternals].withResolvers() resolve(true) t.assert.ok(await promise) }) await t.test('reject', async (t) => { t.plan(1) const { promise, reject } = PonyPromise[kTestInternals].withResolvers() await t.assert.rejects(async () => { reject(Error('reject')) return promise }, { name: 'Error', message: 'reject' }) }) await t.test('thenable', async (t) => { t.plan(1) const { promise, resolve } = PonyPromise.withResolvers() resolve(true) promise.then((value) => { t.assert.ok(value) }) }) })

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/krtw00/search-mcp'

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