Skip to content

Commit 24f7ee6

Browse files
authored
deps: remove sinon (#3171)
1 parent 51a97af commit 24f7ee6

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@
119119
"node-forge": "^1.3.1",
120120
"pre-commit": "^1.2.2",
121121
"proxy": "^2.1.1",
122-
"sinon": "^17.0.1",
123122
"snazzy": "^9.0.0",
124123
"standard": "^17.0.0",
125124
"tsd": "^0.31.0",

test/env-http-proxy-agent.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const { tspl } = require('@matteo.collina/tspl')
44
const { test, describe, after, beforeEach } = require('node:test')
5-
const sinon = require('sinon')
65
const { EnvHttpProxyAgent, ProxyAgent, Agent, fetch, MockAgent } = require('..')
76
const { kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent, kClosed, kDestroyed, kProxy } = require('../lib/core/symbols')
87

@@ -174,15 +173,23 @@ const createEnvHttpProxyAgentWithMocks = (plan = 1, opts = {}) => {
174173
process.env.https_proxy = 'http://localhost:8443'
175174
const dispatcher = new EnvHttpProxyAgent({ ...opts, factory })
176175
const agentSymbols = [kNoProxyAgent, kHttpProxyAgent, kHttpsProxyAgent]
177-
agentSymbols.forEach((agent) => {
178-
sinon.spy(dispatcher[agent], 'dispatch')
176+
agentSymbols.forEach((agentSymbol) => {
177+
const originalDispatch = dispatcher[agentSymbol].dispatch
178+
dispatcher[agentSymbol].dispatch = function () {
179+
dispatcher[agentSymbol].dispatch.called = true
180+
return originalDispatch.apply(this, arguments)
181+
}
182+
dispatcher[agentSymbol].dispatch.called = false
179183
})
180184
const usesProxyAgent = async (agent, url) => {
181185
await fetch(url, { dispatcher })
182186
const result = agentSymbols.every((agentSymbol) => agent === agentSymbol
183-
? dispatcher[agentSymbol].dispatch.called
184-
: dispatcher[agentSymbol].dispatch.notCalled)
185-
agentSymbols.forEach((agent) => { dispatcher[agent].dispatch.resetHistory() })
187+
? dispatcher[agentSymbol].dispatch.called === true
188+
: dispatcher[agentSymbol].dispatch.called === false)
189+
190+
agentSymbols.forEach((agentSymbol) => {
191+
dispatcher[agentSymbol].dispatch.called = false
192+
})
186193
return result
187194
}
188195
const doesNotProxy = usesProxyAgent.bind(this, kNoProxyAgent)

0 commit comments

Comments
 (0)