UNPKG

767 BJavaScriptView Raw
1'use strict'
2
3const t = require('tap')
4const test = t.test
5const { kReplySentOverwritten } = require('../lib/symbols')
6const wrapThenable = require('../lib/wrapThenable')
7
8test('should resolve immediately when reply[kReplySentOverwritten] is true', t => {
9 const reply = {}
10 reply[kReplySentOverwritten] = true
11 const thenable = Promise.resolve()
12 wrapThenable(thenable, reply)
13 t.end()
14})
15
16test('should reject immediately when reply[kReplySentOverwritten] is true', t => {
17 t.plan(1)
18 const reply = { res: {} }
19 reply[kReplySentOverwritten] = true
20 reply.log = {
21 error: ({ err }) => {
22 t.strictEqual(err.message, 'Reply sent already')
23 }
24 }
25
26 const thenable = Promise.reject(new Error('Reply sent already'))
27 wrapThenable(thenable, reply)
28})