Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Feb 5, 2022
1 parent 43cc56e commit 9d09762
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ jobs:

- name: Node.js 6.x
node-version: "6.17"
npm-i: [email protected]
npm-i: [email protected] [email protected]

- name: Node.js 7.x
node-version: "7.10"
npm-i: [email protected]
npm-i: [email protected] [email protected]

- name: Node.js 8.x
node-version: "8.17"
Expand Down
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ install:
# supertest for http calls
# - use 2.0.0 for Node.js < 4
# - use 3.4.2 for Node.js < 6
# - use 6.1.6 for Node.js < 8
if ([int]$env:nodejs_version.split(".")[0] -lt 4) {
npm install --silent --save-dev [email protected]
} elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) {
npm install --silent --save-dev [email protected]
} elseif ([int]$env:nodejs_version.split(".")[0] -lt 8) {
npm install --silent --save-dev [email protected]
}
# Update Node.js modules
- ps: |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"multiparty": "4.2.2",
"pbkdf2-password": "1.2.1",
"should": "13.2.3",
"supertest": "6.1.6",
"supertest": "6.2.2",
"vhost": "~3.0.2"
},
"engines": {
Expand Down
76 changes: 46 additions & 30 deletions test/res.sendFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,11 @@ describe('res', function(){
app.use(function (req, res) {
setImmediate(function () {
res.sendFile(path.resolve(fixtures, 'name.txt'));
server.close(cb)
setTimeout(function () {
cb(error)
}, 10)
})
test.abort();
test.req.abort()
});

app.use(function (err, req, res, next) {
Expand All @@ -127,7 +126,10 @@ describe('res', function(){

var server = app.listen()
var test = request(server).get('/')
test.end()
test.end(function (err) {
assert.ok(err)
server.close(cb)
})
})

describe('with "cacheControl" option', function () {
Expand Down Expand Up @@ -272,43 +274,49 @@ describe('res', function(){
})

it('should invoke the callback when client aborts', function (done) {
var cb = after(1, done);
var cb = after(2, done)
var app = express();

app.use(function (req, res) {
setImmediate(function () {
res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) {
should(err).be.ok()
err.code.should.equal('ECONNABORTED');
server.close(cb)
assert.ok(err)
assert.strictEqual(err.code, 'ECONNABORTED')
cb()
});
});
test.abort();
test.req.abort()
});

var server = app.listen()
var test = request(server).get('/')
test.expect(200, cb);
test.end(function (err) {
assert.ok(err)
server.close(cb)
})
})

it('should invoke the callback when client already aborted', function (done) {
var cb = after(1, done);
var cb = after(2, done)
var app = express();

app.use(function (req, res) {
onFinished(res, function () {
res.sendFile(path.resolve(fixtures, 'name.txt'), function (err) {
should(err).be.ok()
err.code.should.equal('ECONNABORTED');
server.close(cb)
assert.ok(err)
assert.strictEqual(err.code, 'ECONNABORTED')
cb()
});
});
test.abort();
test.req.abort()
});

var server = app.listen()
var test = request(server).get('/')
test.expect(200, cb);
test.end(function (err) {
assert.ok(err)
server.close(cb)
})
})

it('should invoke the callback without error when HEAD', function (done) {
Expand Down Expand Up @@ -398,43 +406,49 @@ describe('res', function(){
})

it('should invoke the callback when client aborts', function (done) {
var cb = after(1, done);
var cb = after(2, done)
var app = express();

app.use(function (req, res) {
setImmediate(function () {
res.sendfile('test/fixtures/name.txt', function (err) {
should(err).be.ok()
err.code.should.equal('ECONNABORTED');
server.close(cb)
assert.ok(err)
assert.strictEqual(err.code, 'ECONNABORTED')
cb()
});
});
test.abort();
test.req.abort()
});

var server = app.listen()
var test = request(server).get('/')
test.expect(200, cb);
test.end(function (err) {
assert.ok(err)
server.close(cb)
})
})

it('should invoke the callback when client already aborted', function (done) {
var cb = after(1, done);
var cb = after(2, done)
var app = express();

app.use(function (req, res) {
onFinished(res, function () {
res.sendfile('test/fixtures/name.txt', function (err) {
should(err).be.ok()
err.code.should.equal('ECONNABORTED');
server.close(cb)
assert.ok(err)
assert.strictEqual(err.code, 'ECONNABORTED')
cb()
});
});
test.abort();
test.req.abort()
});

var server = app.listen()
var test = request(server).get('/')
test.expect(200, cb);
test.end(function (err) {
assert.ok(err)
server.close(cb)
})
})

it('should invoke the callback without error when HEAD', function (done) {
Expand Down Expand Up @@ -652,12 +666,11 @@ describe('res', function(){
app.use(function (req, res) {
setImmediate(function () {
res.sendfile(path.resolve(fixtures, 'name.txt'));
server.close(cb)
setTimeout(function () {
cb(error)
}, 10)
});
test.abort();
test.req.abort()
});

app.use(function (err, req, res, next) {
Expand All @@ -667,7 +680,10 @@ describe('res', function(){

var server = app.listen()
var test = request(server).get('/')
test.end()
test.end(function (err) {
assert.ok(err)
server.close(cb)
})
})

describe('with an absolute path', function(){
Expand Down

0 comments on commit 9d09762

Please sign in to comment.