Skip to content
Myr

req.is.js

This file

Path

test/req.is.js

103 lines · 2.1 KiB · JavaScript

Last changed by

move setHeader charset patch to .setJonathan Ongbefore adoptionbad55f7

History of this file

Take it

The walk stopped after 200 commits: lines older than 2e68ddb point at it.

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 1–2why, one step back
1
2var express = require('../')

remove unnecessary test/support/httpJonathan Ongbefore adoption643397e

line 3why, one step back
3 , request = require('supertest');

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 4–6why, one step back
4
5function req(ct) {6 var req = {

refactor req.is and req.accepts*Jonathan Ongbefore adoptioncec0c06

lines 7–11why, one step back
7 headers: {
8 'content-type': ct,9 'transfer-encoding': 'chunked'10 },11 __proto__: express.request

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 12–18why, one step back
12 };
1314 return req;15}1617describe('req.is()', function(){18 it('should ignore charset', function(){

move setHeader charset patch to .setJonathan Ongbefore adoptionbad55f7

line 19why, one step back
19 req('application/json')

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

line 20why, one step back
20 .is('json')

refactor req.is and req.accepts*Jonathan Ongbefore adoptioncec0c06

line 21why, one step back
21 .should.equal('json');

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 22–35why, one step back
22 })
2324 describe('when content-type is not present', function(){25 it('should return false', function(){26 req('')27 .is('json')28 .should.be.false;29 })30 })3132 describe('when given an extension', function(){33 it('should lookup the mime type', function(){34 req('application/json')35 .is('json')

refactor req.is and req.accepts*Jonathan Ongbefore adoptioncec0c06

line 36why, one step back
36 .should.equal('json');

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 37–47why, one step back
37
38 req('text/html')39 .is('json')40 .should.be.false;41 })42 })4344 describe('when given a mime type', function(){45 it('should match', function(){46 req('application/json')47 .is('application/json')

refactor req.is and req.accepts*Jonathan Ongbefore adoptioncec0c06

line 48why, one step back
48 .should.equal('application/json');

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 49–59why, one step back
49
50 req('image/jpeg')51 .is('application/json')52 .should.be.false;53 })54 })5556 describe('when given */subtype', function(){57 it('should match', function(){58 req('application/json')59 .is('*/json')

refactor req.is and req.accepts*Jonathan Ongbefore adoptioncec0c06

line 60why, one step back
60 .should.equal('application/json');

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 61–70why, one step back
61
62 req('image/jpeg')63 .is('*/json')64 .should.be.false;65 })6667 describe('with a charset', function(){68 it('should match', function(){69 req('text/html; charset=utf-8')70 .is('*/html')

refactor req.is and req.accepts*Jonathan Ongbefore adoptioncec0c06

line 71why, one step back
71 .should.equal('text/html');

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 72–83why, one step back
72
73 req('text/plain; charset=utf-8')74 .is('*/html')75 .should.be.false;76 })77 })78 })7980 describe('when given type/*', function(){81 it('should match', function(){82 req('image/png')83 .is('image/*')

refactor req.is and req.accepts*Jonathan Ongbefore adoptioncec0c06

line 84why, one step back
84 .should.equal('image/png');

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 85–94why, one step back
85
86 req('text/html')87 .is('image/*')88 .should.be.false;89 })9091 describe('with a charset', function(){92 it('should match', function(){93 req('text/html; charset=utf-8')94 .is('text/*')

refactor req.is and req.accepts*Jonathan Ongbefore adoptioncec0c06

line 95why, one step back
95 .should.equal('text/html');

expose connect.middleware using Object.getOwnPropertyDescriptor()Jonathan Ongbefore adoption2e68ddb

lines 96–103why, one step back
96
97 req('something/html; charset=utf-8')98 .is('text/*')99 .should.be.false;100 })101 })102 })103})