download
raw
1.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)
})
})
})

Xet Storage Details

Size:
1.58 kB
·
Xet hash:
050e9fdc2479130dc30c1ca9029d5a233d312d5aa20cf4d62ef07d9591fcc2b4

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.