promise.test.js — fastify Source File
Architecture documentation for promise.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'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)
})
})
})
Source
Frequently Asked Questions
What does promise.test.js do?
promise.test.js is a source file in the fastify codebase, written in javascript.
Where is promise.test.js in the architecture?
promise.test.js is located at test/internals/promise.test.js (directory: test/internals).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free