res.links.js
This file
Path
test/res.links.js
65 lines · 1.8 KiB · JavaScript
Last changed by
feat: Extend res.links() to allow adding multiple links with the same rel (closes #2729) (#4885)Andrea Polverinobefore adoptioncaa4f68
History of this fileTake it
The walk stopped after 200 commits: lines older than 2027b87 point at it.
fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 1–45why, one step back1'use strict'23var express = require('..');4var request = require('supertest');56describe('res', function(){7 describe('.links(obj)', function(){8 it('should set Link header field', function (done) {9 var app = express();1011 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 });1819 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 })2425 it('should set Link header field for multiple calls', function (done) {26 var app = express();2728 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 });3334 res.links({35 prev: 'http://api.example.com/users?page=1'36 });3738 res.end();39 });4041 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 })feat: Extend res.links() to allow adding multiple links with the same rel (closes #2729) (#4885)Andrea Polverinobefore adoptioncaa4f68
lines 46–63why, one step back4647 it('should set multiple links for single rel', function (done) {48 var app = express();4950 app.use(function (req, res) {51 res.links({52 next: 'http://api.example.com/users?page=2',53 last: ['http://api.example.com/users?page=5', 'http://api.example.com/users?page=1']54 });5556 res.end();57 });5859 request(app)60 .get('/')61 .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="last"')62 .expect(200, done);63 })fix(deps): cookie@0.7.0Josh Bukerbefore adoption2027b87
lines 64–65why, one step back64 })65})