var assert = require('assert')
var http = require('http')
var doNotCache = require('./')
var receivedResponse = false
http.createServer()
.on('request', function (request, response) {
doNotCache(response)
response.end()
})
.listen(0 , function () {
var server = this
var port = server.address().port
http.request({port: port})
.on('response', function (response) {
var headers = response.headers
receivedResponse = true
assert(headers['pragma'] === 'no-cache')
assert(headers['expires'] === '0')
assert(
headers['cache-control']
.includes('no-cache')
)
assert(
headers['cache-control']
.includes('no-store')
)
assert(
headers['cache-control']
.includes('must-revalidate')
)
server.close()
})
.end()
})
process.on('exit', function () {
assert(receivedResponse === true)
})