strong-tie/inbound-calls
0
1'use strict'2 3const { test } = require('node:test')4const { kReplyHijacked } = require('../lib/symbols')5const wrapThenable = require('../lib/wrapThenable')6const Reply = require('../lib/reply')7 8test('should resolve immediately when reply[kReplyHijacked] is true', async t => {9 await new Promise(resolve => {10 const reply = {}11 reply[kReplyHijacked] = true12 const thenable = Promise.resolve()13 wrapThenable(thenable, reply)14 resolve()15 })16})17 18test('should reject immediately when reply[kReplyHijacked] is true', t => {19 t.plan(1)20 const reply = new Reply({}, {}, {})21 reply[kReplyHijacked] = true22 reply.log = {23 error: ({ err }) => {24 t.assert.strictEqual(err.message, 'Reply sent already')25 }26 }27 28 const thenable = Promise.reject(new Error('Reply sent already'))29 wrapThenable(thenable, reply)30})31 