Skip to content
Myr

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

8 files+79 added−14 removed

modified:test/app.router.js+2 added-6 removed
39 unmodified lines
40 it('should include ' + method.toUpperCase(), function(done){41 var app = express();4243 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 });4647 request(app)48 [method]('/foo')53 .expect(method === 'head' ? '' : method, done)49 .expect(200, done)50 })5152 it('should reject numbers for app.' + method, function(){53 var app = express();
1031 unmodified lines
modified:test/res.download.js+12 added-1 removed
modified:test/res.redirect.js+13 added-2 removed
12var assert = require('assert')3var express = require('..');4var request = require('supertest');5var utils = require('./support/utils');6
78 unmodified lines
85 });8687 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 })9596 describe('when accepting html', function(){
102 unmodified lines
199200 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})212213function 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 lines
187 });188189 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 })196197 it('should set ETag', function (done) {198 var app = express();
59 unmodified lines
258 });259260 request(app)261 .head('/')260 .expect('', done);262 .expect(200)263 .expect(shouldNotHaveBody())264 .end(done)265 })266 })267268 describe('when .statusCode is 204', function(){
307 unmodified lines
576 })577 })578 })579})580581function 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}590591function shouldNotHaveBody () {592 return function (res) {593 assert.ok(res.text === '' || res.text === undefined)594 }595}
modified:test/res.sendFile.js+17 added-2 removed
12var after = require('after');3var Buffer = require('safe-buffer').Buffer4var express = require('../')5 , request = require('supertest')6 , assert = require('assert');7var onFinished = require('on-finished');
147 unmodified lines
155 var app = createApp(path.resolve(__dirname, 'fixtures/.name'), { dotfiles: 'allow' });156157 request(app)158 .get('/')158 .expect(200, 'tobi', done);159 .expect(200)160 .expect(shouldHaveBody(Buffer.from('tobi')))161 .end(done)162 });163 });164165 describe('with "headers" option', function () {
384 unmodified lines
550 });551552 request(app)553 .get('/')551 .expect(200, 'tobi', done);554 .expect(200)555 .expect(shouldHaveBody(Buffer.from('tobi')))556 .end(done)557 })558559 it('should accept headers option', function(done){560 var app = express();
244 unmodified lines
805 });806807 return app;808}809810function 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 lines
38 # - 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 ]]; then
13 unmodified lines
modified:appveyor.yml+6 added
30 unmodified lines
31 # - 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 lines
modified:package.json+1 added-1 removed
72 unmodified lines
73 "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