req.is.js
This file
Path
test/req.is.js
169 lines · 3.7 KiB · JavaScript
Last changed by
Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
History of this fileTake it
The walk stopped after 200 commits: lines older than 2a0c35a point at it.
Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
line 1why, one step back1'use strict'Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 2why, one step back2Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 3–4why, one step back3var express = require('..')4var request = require('supertest')Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 5why, one step back5Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 6–9why, one step back6describe('req.is()', function () {7 describe('when given a mime type', function () {8 it('should return the type when matching', function (done) {9 var app = express()Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 10why, one step back10Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 11–13why, one step back11 app.use(function (req, res) {12 res.json(req.is('application/json'))13 })Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 14why, one step back14Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 15–48why, one step back15 request(app)16 .post('/')17 .type('application/json')18 .send('{}')19 .expect(200, '"application/json"', done)20 })2122 it('should return false when not matching', function (done) {23 var app = express()2425 app.use(function (req, res) {26 res.json(req.is('image/jpeg'))27 })2829 request(app)30 .post('/')31 .type('application/json')32 .send('{}')33 .expect(200, 'false', done)34 })3536 it('should ignore charset', function (done) {37 var app = express()3839 app.use(function (req, res) {40 res.json(req.is('application/json'))41 })4243 request(app)44 .post('/')45 .type('application/json; charset=UTF-8')46 .send('{}')47 .expect(200, '"application/json"', done)48 })Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 49–51why, one step back49 })5051 describe('when content-type is not present', function(){Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 52–62why, one step back52 it('should return false', function (done) {53 var app = express()5455 app.use(function (req, res) {56 res.json(req.is('application/json'))57 })5859 request(app)60 .post('/')61 .send('{}')62 .expect(200, 'false', done)Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 63–66why, one step back63 })64 })6566 describe('when given an extension', function(){Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 67–68why, one step back67 it('should lookup the mime type', function (done) {68 var app = express()Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 69why, one step back69Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 70–78why, one step back70 app.use(function (req, res) {71 res.json(req.is('json'))72 })7374 request(app)75 .post('/')76 .type('application/json')77 .send('{}')78 .expect(200, '"json"', done)Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 79–81why, one step back79 })80 })81Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 82–84why, one step back82 describe('when given */subtype', function(){83 it('should return the full type when matching', function (done) {84 var app = express()Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 85why, one step back85Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 86–94why, one step back86 app.use(function (req, res) {87 res.json(req.is('*/json'))88 })8990 request(app)91 .post('/')92 .type('application/json')93 .send('{}')94 .expect(200, '"application/json"', done)Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 95–96why, one step back95 })96Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 97–98why, one step back97 it('should return false when not matching', function (done) {98 var app = express()Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 99why, one step back99Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 100–108why, one step back100 app.use(function (req, res) {101 res.json(req.is('*/html'))102 })103104 request(app)105 .post('/')106 .type('application/json')107 .send('{}')108 .expect(200, 'false', done)Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 109–110why, one step back109 })110Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 111–112why, one step back111 it('should ignore charset', function (done) {112 var app = express()Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 113why, one step back113Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 114–115why, one step back114 app.use(function (req, res) {115 res.json(req.is('*/json'))Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 116why, one step back116 })Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 117–122why, one step back117118 request(app)119 .post('/')120 .type('application/json; charset=UTF-8')121 .send('{}')122 .expect(200, '"application/json"', done)Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 123–126why, one step back123 })124 })125126 describe('when given type/*', function(){Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 127–128why, one step back127 it('should return the full type when matching', function (done) {128 var app = express()Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 129why, one step back129Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 130–138why, one step back130 app.use(function (req, res) {131 res.json(req.is('application/*'))132 })133134 request(app)135 .post('/')136 .type('application/json')137 .send('{}')138 .expect(200, '"application/json"', done)Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 139–140why, one step back139 })140Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 141–142why, one step back141 it('should return false when not matching', function (done) {142 var app = express()Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 143why, one step back143Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 144–145why, one step back144 app.use(function (req, res) {145 res.json(req.is('text/*'))Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
line 146why, one step back146 })Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e
lines 147–166why, one step back147148 request(app)149 .post('/')150 .type('application/json')151 .send('{}')152 .expect(200, 'false', done)153 })154155 it('should ignore charset', function (done) {156 var app = express()157158 app.use(function (req, res) {159 res.json(req.is('application/*'))160 })161162 request(app)163 .post('/')164 .type('application/json; charset=UTF-8')165 .send('{}')166 .expect(200, '"application/json"', done)Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 167–169why, one step back167 })168 })169})