make sure /sessions doesn't return false hard-coded information

Fixes #400
This commit is contained in:
Jonathan Lipps
2013-04-08 15:03:56 -07:00
parent 19e49ab39b
commit edf29b5b72
2 changed files with 19 additions and 3 deletions
+9 -2
View File
@@ -177,8 +177,15 @@ exports.getSession = function(req, res) {
};
exports.getSessions = function(req, res) {
respondSuccess(req, res,
[{id: req.appium.sessionId , capabilities: req.device.capabilities}]);
var sessions = [];
if (req.appium.sessionId !== null) {
sessions.push({
id: req.appium.sessionId
, capabilities: req.device.capabilities
});
}
respondSuccess(req, res, sessions);
};
exports.reset = function(req, res) {
+10 -1
View File
@@ -19,7 +19,7 @@ var describeWithSession = function(desc, tests) {
should.not.exist(err);
res.statusCode.should.equal(303);
should.ok(res.headers.location);
request.get(serverUrl + res.headers.location, function(err, res, body) {
request.get(res.headers.location, function(err, res, body) {
should.not.exist(err);
res.statusCode.should.equal(200);
body = JSON.parse(body);
@@ -54,6 +54,15 @@ describe('JSONWP request', function() {
});
});
});
describe('to get list of sessions', function() {
it('should return empty list if no session active', function(done) {
request.get(serverHub + 's', function(err, res, body) {
should.not.exist(err);
JSON.parse(body).value.should.eql([]);
done();
});
});
});
describe('to a not-yet-implemented url', function() {
it('should respond with 501 Not Implemented', function(done) {
var url = serverHub + '/fakesessid/ime/deactivate';