1 | 'use strict'
|
2 |
|
3 | const t = require('tap')
|
4 | const test = t.test
|
5 | const { kReplySentOverwritten } = require('../lib/symbols')
|
6 | const wrapThenable = require('../lib/wrapThenable')
|
7 |
|
8 | test('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 |
|
16 | test('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 | })
|