Skip to content
Myr

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 file

Take 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 back
1'use strict'

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

line 2why, one step back
2

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 3–4why, one step back
3var express = require('..')
4var request = require('supertest')

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

line 5why, one step back
5

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 6–9why, one step back
6describe('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 back
10

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 11–13why, one step back
11 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 back
14

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 15–48why, one step back
15 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 back
49 })
5051 describe('when content-type is not present', function(){

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 52–62why, one step back
52 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 back
63 })
64 })6566 describe('when given an extension', function(){

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 67–68why, one step back
67 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 back
69

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 70–78why, one step back
70 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 back
79 })
80 })81

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 82–84why, one step back
82 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 back
85

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 86–94why, one step back
86 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 back
95 })
96

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 97–98why, one step back
97 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 back
99

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 100–108why, one step back
100 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 back
109 })
110

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 111–112why, one step back
111 it('should ignore charset', function (done) {
112 var app = express()

Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a

line 113why, one step back
113

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 114–115why, one step back
114 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 back
116 })

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 117–122why, one step back
117
118 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 back
123 })
124 })125126 describe('when given type/*', function(){

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 127–128why, one step back
127 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 back
129

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 130–138why, one step back
130 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 back
139 })
140

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 141–142why, one step back
141 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 back
143

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 144–145why, one step back
144 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 back
146 })

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 147–166why, one step back
147
148 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 back
167 })
168 })169})