Skip to content

Commit

Permalink
Test global agent settings work
Browse files Browse the repository at this point in the history
  • Loading branch information
ozzywalsh committed Jan 19, 2019
1 parent 713ddf1 commit 3b13e91
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions test/supertest.js
Expand Up @@ -833,7 +833,8 @@ describe('request(app)', function () {

describe('request.agent(app)', function () {
const app = express();
const agent = request.agent(app);
const agent = request.agent(app)
.set('header', 'hey');

app.use(cookieParser());

Expand All @@ -842,11 +843,16 @@ describe('request.agent(app)', function () {
res.send();
});

app.get('/return', function (req, res) {
app.get('/return_cookies', function (req, res) {
if (req.cookies.cookie) res.send(req.cookies.cookie);
else res.send(':(');
});

app.get('/return_headers', function (req, res) {
if (req.get('header')) res.send(req.get('header'));
else res.send(':(');
});

it('should save cookies', function (done) {
agent
.get('/')
Expand All @@ -855,7 +861,13 @@ describe('request.agent(app)', function () {

it('should send cookies', function (done) {
agent
.get('/return')
.get('/return_cookies')
.expect('hey', done);
});

it('should send global agent headers', function (done) {
agent
.get('/return_headers')
.expect('hey', done);
});
});
Expand Down

0 comments on commit 3b13e91

Please sign in to comment.