Skip to content
Myr

Added tests for res.redirect()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent c77ecbb · Browse files · 2 files+62 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+62 added−5 removed

  • tests:+58 added−0 removed
  • other:+4 added−5 removed

2 files+62 added−5 removed

modified:lib/express/response.js+4 added-5 removed
modified:test/response.test.js+58 added
88 unmodified lines
89 { body: 'whatever', headers: { 'Content-Disposition': 'attachment; filename="jquery.js"' }});90 assert.response(app,91 { url: '/style.css' },92 { body: 'some stylezzz', headers: { 'Content-Disposition': 'attachment' }});93 },94 95 '#redirect()': function(assert){96 var app = express.createServer(),97 app2 = express.createServer();98 99 app2.set('home', '/blog');100101 app.get('/', function(req, res){102 res.redirect('http://google.com', 301);103 });104 105 app.get('/back', function(req, res){106 res.redirect('back');107 });108 109 app.get('/home', function(req, res){110 res.redirect('home');111 });112 113 app2.get('/', function(req, res){114 res.redirect('http://google.com', 301);115 });116 117 app2.get('/back', function(req, res){118 res.redirect('back');119 });120 121 app2.get('/home', function(req, res){122 res.redirect('home');123 });124 125 assert.response(app,126 { url: '/' },127 { body: '', status: 301, headers: { Location: 'http://google.com' }});128 assert.response(app,129 { url: '/back' },130 { body: '', status: 302, headers: { Location: '/' }});131 assert.response(app,132 { url: '/back', headers: { Referer: '/foo' }},133 { body: '', status: 302, headers: { Location: '/foo' }});134 assert.response(app,135 { url: '/back', headers: { Referrer: '/foo' }},136 { body: '', status: 302, headers: { Location: '/foo' }});137 assert.response(app,138 { url: '/home' },139 { body: '', status: 302, headers: { Location: '/' }});140141 assert.response(app2,142 { url: '/' },143 { body: '', status: 301, headers: { Location: 'http://google.com' }});144 assert.response(app2,145 { url: '/back' },146 { body: '', status: 302, headers: { Location: '/blog' }});147 assert.response(app2,148 { url: '/home' },149 { body: '', status: 302, headers: { Location: '/blog' }});150 151 }152};