Skip to content

Commit

Permalink
Enable sessions on existing servers (fixes #30)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjz committed Jan 24, 2018
1 parent 1070373 commit 3ae4930
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ function Session (app, options) {

if (typeof app === 'function') {
app = http.createServer(app);
}

if (app instanceof http.Server) {
url = supertest.Test.prototype.serverAddress(app, '/');
}

Expand Down
13 changes: 13 additions & 0 deletions test/main_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ describe('supertest-session', function () {
.end(done);
});
});

describe('(#30) requesting URL of instantiated app', function () {
it('behaves correctly', function (done) {
var server = http.createServer(app);
var sess = session(server);
sess
.get('/')
.expect(200)
.expect('GET,,1')
.end(done);
});
});

});

describe('Session with a .before hook', function () {
Expand Down

0 comments on commit 3ae4930

Please sign in to comment.