Skip to content
Myr

moved jsonp tests

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 796aaff · Browse files · 2 files+47 added−42 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+47 added−42 removed

  • tests:+46 added−42 removed
  • other:+1 added−0 removed

2 files+47 added−42 removed

modified:docs/guide.md+1 added
103 unmodified lines
104 * _view options_ An object specifying global view options105 * _view cache_ Enable view caching (enabled in production)106 * _case sensitive routes_ Enable case-sensitive routing107 * _strict routing_ When enabled trailing slashes are no longer ignored108 * _jsonp callback_ Enable _res.send()_ / _res.json()_ transparent jsonp support109110### Routing111112Express utilizes the HTTP verbs to provide a meaningful, expressive routing API.
1298 unmodified lines
modified:test/response.test.js+46 added-42 removed
70 unmodified lines
71 res.header('X-Foo', 'bar');72 res.send({ foo: 'bar' }, { 'X-Foo': 'baz' }, 201);73 });74 75 app.get('/jsonp', function(req, res){76 app.enable('jsonp callback');77 res.header('X-Foo', 'bar');78 res.send({ foo: 'bar' }, { 'X-Foo': 'baz' }, 201);79 app.disable('jsonp callback');80 });81 75 app.get('/text', function(req, res){76 res.header('X-Foo', 'bar');77 res.contentType('txt');78 res.send('wahoo');
49 unmodified lines
128 , 'X-Foo': 'baz'129 }});130 131 assert.response(app,139 { url: '/jsonp?callback=test' },140 { body: 'test({"foo":"bar"});'141 , status: 201142 , headers: {143 'Content-Type': 'text/javascript; charset=utf-8'144 , 'X-Foo': 'baz'145 }});146 147 assert.response(app,148 { url: '/jsonp?callback=baz' },149 { body: 'baz({"foo":"bar"});'150 , status: 201, headers: {151 'Content-Type': 'text/javascript; charset=utf-8'152 , 'X-Foo': 'baz'153 }});154 155 assert.response(app,156 { url: '/jsonp?callback=invalid()[]' },157 { body: 'invalid({"foo":"bar"});'158 , status: 201159 , headers: {160 'Content-Type': 'text/javascript; charset=utf-8'161 , 'X-Foo': 'baz'162 }});163 164 assert.response(app,165 { url: '/json?callback=test' },166 { body: '{"foo":"bar"}'167 , status: 201168 , headers: {169 'Content-Type': 'application/json; charset=utf-8'170 , 'X-Foo': 'baz'171 }});172 173 assert.response(app,132 { url: '/text' },133 { body: 'wahoo'134 , headers: {135 'Content-Type': 'text/plain'
39 unmodified lines
175 { status: 204 }, function(res){176 assert.equal(undefined, res.headers['content-type']);177 assert.equal(undefined, res.headers['content-length']);178 });179180 assert.response(app,181 { url: '/json?callback=test' },182 { body: '{"foo":"bar"}'183 , status: 201184 , headers: {185 'Content-Type': 'application/json; charset=utf-8'186 , 'X-Foo': 'baz'187 }});188 },189190 'test #send() JSONP': function(){191 var app = express.createServer();192193 app.enable('jsonp callback');194195 app.get('/jsonp', function(req, res){196 res.header('X-Foo', 'bar');197 res.send({ foo: 'bar' }, { 'X-Foo': 'baz' }, 201);198 });199200 assert.response(app,201 { url: '/jsonp?callback=test' },202 { body: 'test({"foo":"bar"});'203 , status: 201204 , headers: {205 'Content-Type': 'text/javascript; charset=utf-8'206 , 'X-Foo': 'baz'207 }});208 209 assert.response(app,210 { url: '/jsonp?callback=baz' },211 { body: 'baz({"foo":"bar"});'212 , status: 201, headers: {213 'Content-Type': 'text/javascript; charset=utf-8'214 , 'X-Foo': 'baz'215 }});216 217 assert.response(app,218 { url: '/jsonp?callback=invalid()[]' },219 { body: 'invalid({"foo":"bar"});'220 , status: 201221 , headers: {222 'Content-Type': 'text/javascript; charset=utf-8'223 , 'X-Foo': 'baz'224 }});225 },226227 'test #contentType()': function(){228 var app = express.createServer();229 230 app.get('/html', function(req, res){
506 unmodified lines