deps: body-parser@1.20.0
[express.git] / test / res.links.js
blob240b7fcfda34cb433924b3fba6d9f7ef2dd58178
1 'use strict'
3 var express = require('..');
4 var request = require('supertest');
6 describe('res', function(){
7   describe('.links(obj)', function(){
8     it('should set Link header field', function (done) {
9       var app = express();
11       app.use(function (req, res) {
12         res.links({
13           next: 'http://api.example.com/users?page=2',
14           last: 'http://api.example.com/users?page=5'
15         });
16         res.end();
17       });
19       request(app)
20       .get('/')
21       .expect('Link', '<http://api.example.com/users?page=2>; rel="next", <http://api.example.com/users?page=5>; rel="last"')
22       .expect(200, done);
23     })
25     it('should set Link header field for multiple calls', function (done) {
26       var app = express();
28       app.use(function (req, res) {
29         res.links({
30           next: 'http://api.example.com/users?page=2',
31           last: 'http://api.example.com/users?page=5'
32         });
34         res.links({
35           prev: 'http://api.example.com/users?page=1'
36         });
38         res.end();
39       });
41       request(app)
42       .get('/')
43       .expect('Link', '<http://api.example.com/users?page=2>; rel="next", <http://api.example.com/users?page=5>; rel="last", <http://api.example.com/users?page=1>; rel="prev"')
44       .expect(200, done);
45     })
46   })