Skip to content

Commit

Permalink
Added test cases to check for res._header and res.headersSent equ…
Browse files Browse the repository at this point in the history
…ivalence
  • Loading branch information
lamweili committed Aug 3, 2022
1 parent 416ae6f commit 35880d6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,25 @@ describe('session()', function(){
})
});

describe('res._header patch', function () {
it('should be equivalent to res.headersSent', function (done) {
request(createServer(function(req, res) {
assert.strictEqual(!!res._header, !!res.headersSent,
'res._header should be equal to res.headersSent (prior state change)')

var oldState = !!res._header;
res.end('ended')
var newState = !!res._header;
assert.notStrictEqual(oldState, newState)

assert.strictEqual(!!res._header, !!res.headersSent,
'res._header should be equal to res.headersSent (after state change)')
}))
.get('/')
.expect(200, 'ended', done)
})
})

describe('res.end patch', function () {
it('should correctly handle res.end/res.write patched prior', function (done) {
function setup (req, res) {
Expand Down

0 comments on commit 35880d6

Please sign in to comment.