Skip to content

Commit

Permalink
fixed eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
refractalize committed Feb 28, 2018
1 parent 2a5812c commit 9b36d8c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"extends": [
"standard",
"plugin:es5/no-es2015"
]
],
"rules": {
"es5/no-es6-methods": 0
}
}
31 changes: 19 additions & 12 deletions test/httpismSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1639,13 +1639,20 @@ describe('httpism', function () {

describe('timeouts', function () {
it('can set the timeout', function () {
var respond

app.get('/', function (req, res) {
// don't respond
// don't respond yet
respond = function () {
res.send()
}
})

var startTime = Date.now()
return expect(httpism.get(baseurl, {timeout: 20})).to.eventually.be.rejectedWith('timeout').then(function () {
expect(Date.now() - startTime).to.be.within(20, 50)
}).then(function () {
respond()
})
})
})
Expand Down Expand Up @@ -1696,15 +1703,15 @@ describe('httpism', function () {
})
})

function streamToBuffer (stream) {
function streamToBytes (stream) {
return new Promise(function (resolve, reject) {
var buffers = []
stream.on('data', function (buffer) {
buffers.push(buffer)
})
stream.on('error', reject)
stream.on('end', function () {
resolve(Buffer.concat(buffers))
resolve(Array.from(Buffer.concat(buffers))) // eslint-disable-line es5/no-es6-static-methods
})
})
}
Expand All @@ -1713,26 +1720,26 @@ describe('httpism', function () {
var http = httpism.client(cache({url: cachePath}), {response: true})
return http.get(baseurl + '/binary').then(function (response) {
expect(response.headers['x-version']).to.eql('1')
return streamToBuffer(response.body)
}).then(function (buffer) {
expect(Array.from(buffer.values())).to.eql([1, 3, 3, 7, 1])
return streamToBytes(response.body)
}).then(function (bytes) {
expect(bytes).to.eql([1, 3, 3, 7, 1])
}).then(function () {
version++
return http.get(baseurl + '/binary')
}).then(function (response) {
expect(response.headers['x-version']).to.eql('1')
return streamToBuffer(response.body)
}).then(function (buffer) {
expect(Array.from(buffer.values())).to.eql([1, 3, 3, 7, 1])
return streamToBytes(response.body)
}).then(function (bytes) {
expect(bytes).to.eql([1, 3, 3, 7, 1])
}).then(function () {
return clearCache()
}).then(function () {
return http.get(baseurl + '/binary')
}).then(function (response) {
expect(response.headers['x-version']).to.eql('2')
return streamToBuffer(response.body)
}).then(function (buffer) {
expect(Array.from(buffer.values())).to.eql([1, 3, 3, 7, 2])
return streamToBytes(response.body)
}).then(function (bytes) {
expect(bytes).to.eql([1, 3, 3, 7, 2])
})
})
})
Expand Down

0 comments on commit 9b36d8c

Please sign in to comment.