saucelabs
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -262,3 +262,3 @@ var crypto = require('crypto'); | ||
'Content-Type': 'application/json', | ||
'Content-Length': body != null ? body.length : 0 | ||
'Content-Length': body != null ? Buffer.byteLength(body) : 0 | ||
} | ||
@@ -297,22 +297,24 @@ }); | ||
var result = ''; | ||
response | ||
.on('data', function (chunk) { | ||
result += chunk; | ||
}) | ||
.on('end', function () { | ||
var res; | ||
if (callback) { | ||
response | ||
.on('data', function (chunk) { | ||
result += chunk; | ||
}) | ||
.on('end', function () { | ||
var res; | ||
try { | ||
res = JSON.parse(result); | ||
} catch (e) { | ||
callback('Could not parse response: ' + result); | ||
return; | ||
} | ||
try { | ||
res = JSON.parse(result); | ||
} catch (e) { | ||
callback('Could not parse response: ' + result); | ||
return; | ||
} | ||
if (response.statusCode === 200) { | ||
callback(null, res); | ||
} else { | ||
callback(res); | ||
} | ||
}); | ||
if (response.statusCode === 200) { | ||
callback(null, res); | ||
} else { | ||
callback(res); | ||
} | ||
}); | ||
} | ||
}); | ||
@@ -319,0 +321,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "A wrapper around Sauce Labs REST API", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"homepage": "https://github.com/holidayextras/node-saucelabs", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -141,2 +141,9 @@ describe('SauceLabs', function () { | ||
}); | ||
it('doesnt require a callback', function (done) { | ||
var id = '01230123-example-id-1234'; | ||
var mock = nockle.put('/rest/v1/:username/jobs/:id', { id: id }); | ||
sauce.updateJob(id, {}); | ||
done(); | ||
}); | ||
}); | ||
@@ -143,0 +150,0 @@ |
32596
638