Skip to content

Commit

Permalink
fix: linting (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Aug 15, 2022
1 parent ee20fc2 commit e9a2a51
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 29 deletions.
1 change: 1 addition & 0 deletions lib/cache/entry.js
Expand Up @@ -288,6 +288,7 @@ class CacheEntry {
// stick a flag on here so downstream users will know if they can expect integrity events
tee.pipe(cacheStream)
// TODO if the cache write fails, log a warning but return the response anyway
// eslint-disable-next-line promise/catch-or-return
cacheStream.promise().then(cacheWriteResolve, cacheWriteReject)
body.unshift(tee)
body.unshift(this.response.body)
Expand Down
42 changes: 13 additions & 29 deletions test/fetch.js
Expand Up @@ -495,16 +495,14 @@ t.test('supports proxy configurations', { skip: true }, async (t) => {
}).listen(9854).on('error', err => {
throw err
})
fetch('http://npm.im/make-fetch-happen', {
const res = await fetch('http://npm.im/make-fetch-happen', {
proxy: 'http://localhost:9854',
retry: {
retries: 0,
},
}).then(res => {
return res.buffer()
}).then(buf => {
t.same(buf, CONTENT, 'request succeeded')
})
const buf = await res.buffer()
t.same(buf, CONTENT, 'request succeeded')
})

t.test('supports custom agent config', async (t) => {
Expand Down Expand Up @@ -558,31 +556,17 @@ t.test('handle integrity options', async (t) => {
.twice()
.reply(200, data)

const firstFetch = fetch(`${HOST}/integrity`, { integrity })
.then((res) => {
t.equal(res.status, 200, 'successful status code')
t.ok(Minipass.isStream(res.body), 'body is a stream')
return res.buffer()
})
.then((buf) => {
t.same(buf.toString(), data, 'request succeeded')
})

// 100% branch coverage
const secondFetch = fetch(`${HOST}/integrity`, { integrity })
.then((res) => {
t.equal(res.status, 200, 'successful status code')
t.ok(Minipass.isStream(res.body), 'body is a stream')
return res.buffer()
})
.then((buf) => {
t.same(buf.toString(), data, 'request succeeded')
})

await Promise.resolve()
.then(() => firstFetch)
.then(() => secondFetch)
const firstRes = await fetch(`${HOST}/integrity`, { integrity })
t.equal(firstRes.status, 200, 'successful status code')
t.ok(Minipass.isStream(firstRes.body), 'body is a stream')
const firstBuf = await firstRes.buffer()
t.same(firstBuf.toString(), data, 'request succeeded')

const secondRes = await fetch(`${HOST}/integrity`, { integrity })
t.equal(secondRes.status, 200, 'successful status code')
t.ok(Minipass.isStream(secondRes.body), 'body is a stream')
const secondBuf = await secondRes.buffer()
t.same(secondBuf.toString(), data, 'request succeeded')
t.ok(srv.isDone())
})

Expand Down

0 comments on commit e9a2a51

Please sign in to comment.