build: supertest@3.3.0
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Douglas Christopher Wilson · committed by Douglas Christopher Wilson · parent f07f368 · Browse files · 8 files·+79 added−14 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
8 files+79 added−14 removed
- tests:+66 added−13 removed
- other:+13 added−1 removed
Provenance
- Commit
451ee5d- Tree
4d384d9- Author
Douglas Christopher Wilson <doug@somethingdoug.com>- Committer
Douglas Christopher Wilson <doug@somethingdoug.com>- Parent
f07f368
8 files changed+79 added−14 removed
modified:test/app.router.js+2 added-6 removed
39 unmodified lines40 it('should include ' + method.toUpperCase(), function(done){41 var app = express();42 43 app[method]('/foo', function(req, res){44- if (method === 'head') {45- res.end();46- } else {47- res.end(method);48- }44+ res.send(method)45 });46 47 request(app)48 [method]('/foo')53- .expect(method === 'head' ? '' : method, done)49+ .expect(200, done)50 })51 52 it('should reject numbers for app.' + method, function(){53 var app = express();1031 unmodified linesmodified:test/res.download.js+12 added-1 removed
1234567895 unmodified lines10410510610710710810911011111272 unmodified lines185186187188189190191192193194195196197198199200201202203
var after = require('after');var assert = require('assert');var Buffer = require('safe-buffer').Buffervar express = require('..');var request = require('supertest');
describe('res', function(){95 unmodified lines .get('/') .expect(200) .expect('Content-Disposition', 'attachment; filename="document"') .expect('Cache-Control', 'public, max-age=14400') .expect('tobi') .expect(shouldHaveBody(Buffer.from('tobi'))) .end(done) })
describe('when options.headers contains Content-Disposition', function () {72 unmodified lines }) })})
function shouldHaveBody (buf) { return function (res) { var body = !Buffer.isBuffer(res.body) ? Buffer.from(res.text) : res.body assert.ok(body, 'response has body') assert.strictEqual(body.toString('hex'), buf.toString('hex')) }}
function shouldNotHaveHeader(header) { return function (res) { assert.ok(!(header.toLowerCase() in res.headers), 'should not have header ' + header); };}modified:test/res.redirect.js+13 added-2 removed
1 2+var assert = require('assert')3 var express = require('..');4 var request = require('supertest');5 var utils = require('./support/utils');6 78 unmodified lines85 });86 87 request(app)88 .head('/')89+ .expect(302)90 .expect('Location', 'http://google.com')89- .expect(302, '', done)91+ .expect(shouldNotHaveBody())92+ .end(done)93 })94 })95 96 describe('when accepting html', function(){102 unmodified lines199 200 request(app)201 .get('/')202 .set('Accept', 'application/octet-stream')203+ .expect(302)204 .expect('location', 'http://google.com')205 .expect('content-length', '0')206 .expect(utils.shouldNotHaveHeader('Content-Type'))203- .expect(302, '', done)207+ .expect(shouldNotHaveBody())208+ .end(done)209 })210 })211 })212+213+function shouldNotHaveBody () {214+ return function (res) {215+ assert.ok(res.text === '' || res.text === undefined)216+ }217+}modified:test/res.send.js+22 added-2 removed
186 unmodified lines187 });188 189 request(app)190 .get('/')191+ .expect(200)192 .expect('Content-Type', 'application/octet-stream')192- .expect(200, 'hello', done);193+ .expect(shouldHaveBody(Buffer.from('hello')))194+ .end(done)195 })196 197 it('should set ETag', function (done) {198 var app = express();59 unmodified lines258 });259 260 request(app)261 .head('/')260- .expect('', done);262+ .expect(200)263+ .expect(shouldNotHaveBody())264+ .end(done)265 })266 })267 268 describe('when .statusCode is 204', function(){307 unmodified lines576 })577 })578 })579 })580+581+function shouldHaveBody (buf) {582+ return function (res) {583+ var body = !Buffer.isBuffer(res.body)584+ ? Buffer.from(res.text)585+ : res.body586+ assert.ok(body, 'response has body')587+ assert.strictEqual(body.toString('hex'), buf.toString('hex'))588+ }589+}590+591+function shouldNotHaveBody () {592+ return function (res) {593+ assert.ok(res.text === '' || res.text === undefined)594+ }595+}modified:test/res.sendFile.js+17 added-2 removed
1 2 var after = require('after');3+var Buffer = require('safe-buffer').Buffer4 var express = require('../')5 , request = require('supertest')6 , assert = require('assert');7 var onFinished = require('on-finished');147 unmodified lines155 var app = createApp(path.resolve(__dirname, 'fixtures/.name'), { dotfiles: 'allow' });156 157 request(app)158 .get('/')158- .expect(200, 'tobi', done);159+ .expect(200)160+ .expect(shouldHaveBody(Buffer.from('tobi')))161+ .end(done)162 });163 });164 165 describe('with "headers" option', function () {384 unmodified lines550 });551 552 request(app)553 .get('/')551- .expect(200, 'tobi', done);554+ .expect(200)555+ .expect(shouldHaveBody(Buffer.from('tobi')))556+ .end(done)557 })558 559 it('should accept headers option', function(done){560 var app = express();244 unmodified lines805 });806 807 return app;808 }809+810+function shouldHaveBody (buf) {811+ return function (res) {812+ var body = !Buffer.isBuffer(res.body)813+ ? Buffer.from(res.text)814+ : res.body815+ assert.ok(body, 'response has body')816+ assert.strictEqual(body.toString('hex'), buf.toString('hex'))817+ }818+}modified:.travis.yml+6 added
37 unmodified lines38 # - use 3.x for Node.js < 639 if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 6 ]]; then40 npm install --silent --save-dev mocha@3.5.341 fi42+ - |43+ # supertest for http calls44+ # - use 2.0.0 for Node.js < 445+ if [[ "$(cut -d. -f1 <<< "$TRAVIS_NODE_VERSION")" -lt 4 ]]; then46+ npm install --silent --save-dev supertest@2.0.047+ fi48 # Update Node.js modules49 - |50 # Prune and rebuild node_modules51 if [[ -d node_modules ]]; then13 unmodified linesmodified:appveyor.yml+6 added
30 unmodified lines31 # - use 3.x for Node.js < 632 if ($env:nodejs_version.split(".")[0] -lt 6) {33 npm install --silent --save-dev mocha@3.5.334 }35+ - ps: |36+ # supertest for http calls37+ # - use 2.0.0 for Node.js < 438+ if ($env:nodejs_version.split(".")[0] -lt 4) {39+ npm install --silent --save-dev supertest@2.0.040+ }41 # Update Node.js modules42 - ps: |43 # Prune & rebuild node_modules44 if (Test-Path -Path node_modules) {16 unmodified linesmodified:package.json+1 added-1 removed
72 unmodified lines73 "morgan": "1.9.1",74 "multiparty": "4.2.1",75 "pbkdf2-password": "1.2.1",76 "should": "13.2.3",77- "supertest": "2.0.0",77+ "supertest": "3.3.0",78 "connect-redis": "~2.4.1",79 "vhost": "~3.0.2"80 },81 "engines": {17 unmodified lines