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 9e240a5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,29 @@ describe('session()', function(){
})
});

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

res.end('ended')

var afterHeader = !!res._header
var afterHeadersSent = !!res.headersSent
assert.strictEqual(afterHeader, afterHeadersSent,
'res._header should be equal to res.headersSent (after state change)')

assert.notStrictEqual(priorHeader, afterHeader)
assert.notStrictEqual(priorHeadersSent, afterHeadersSent)
}))
.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 9e240a5

Please sign in to comment.