Chrome DevTools for coding agents
test: use sinon.assert for stub call checks (#3297)
Nikolay Vitkov920c9133b15e
diff --git a/tests/ToolHandler.test.ts b/tests/ToolHandler.test.tsindex 1e3fd8c7..feab73db 100644--- a/tests/ToolHandler.test.ts+++ b/tests/ToolHandler.test.ts@@ -1115,7 +1115,7 @@ describe('ToolHandler', () => {assert.strictEqual(result.isError, undefined);assert.strictEqual(handlerCalled, true);- assert.strictEqual(mockContext.validatePath.callCount, 3);+ sinon.assert.callCount(mockContext.validatePath, 3);assert.strictEqual(mockContext.validatePath.calledWith(testFile), true);assert.strictEqual(mockContext.validatePath.calledWith(testListFile1),diff --git a/tests/telemetry/watchdog/ClearcutSender.test.ts b/tests/telemetry/watchdog/ClearcutSender.test.tsindex 518ce4eb..984d3f9c 100644--- a/tests/telemetry/watchdog/ClearcutSender.test.ts+++ b/tests/telemetry/watchdog/ClearcutSender.test.ts@@ -54,7 +54,7 @@ describe('ClearcutSender', () => {await clock.tickAsync(FLUSH_INTERVAL_MS);sender.stopForTesting();- assert.strictEqual(fetchStub.callCount, 1);+ sinon.assert.callCount(fetchStub, 1);const requestBody = JSON.parse(fetchStub.firstCall.args[1].body,) as LogRequest;@@ -80,7 +80,7 @@ describe('ClearcutSender', () => {});assert.strictEqual(sender.bufferSizeForTesting, 2);- assert.strictEqual(fetchStub.callCount, 0);+ sinon.assert.callCount(fetchStub, 0);sender.stopForTesting();});@@ -198,7 +198,7 @@ describe('ClearcutSender', () => {await sender.sendShutdownEvent();- assert.strictEqual(fetchStub.callCount, 1);+ sinon.assert.callCount(fetchStub, 1);const requestBody = JSON.parse(fetchStub.firstCall.args[1].body,) as LogRequest;@@ -292,7 +292,7 @@ describe('ClearcutSender', () => {resolveFirstRequest!(new Response(JSON.stringify({}), {status: 200}));await shutdownPromise;- assert.strictEqual(fetchStub.callCount, 2);+ sinon.assert.callCount(fetchStub, 2);const firstBody = JSON.parse(fetchStub.args[0][1].body) as LogRequest;const secondBody = JSON.parse(fetchStub.args[1][1].body) as LogRequest;diff --git a/tests/utils/check-for-updates.test.ts b/tests/utils/check-for-updates.test.tsindex 96f6fe30..7d55c3af 100644--- a/tests/utils/check-for-updates.test.ts+++ b/tests/utils/check-for-updates.test.ts@@ -40,10 +40,10 @@ describe('checkForUpdates', () => {await checkForUpdates('Run `npm update` to update.');- assert.ok(warnStub.notCalled);- assert.ok(spawnStub.notCalled);- assert.ok(readFileStub.notCalled);- assert.ok(statStub.notCalled);+ sinon.assert.notCalled(warnStub);+ sinon.assert.notCalled(spawnStub);+ sinon.assert.notCalled(readFileStub);+ sinon.assert.notCalled(statStub);delete process.env['CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS'];});@@ -64,12 +64,11 @@ describe('checkForUpdates', () => {await checkForUpdates('Run `npm update` to update.');- assert.ok(- warnStub.calledWith(- sinon.match('Update available: ' + VERSION + ' -> 99.9.9'),- ),+ sinon.assert.calledWith(+ warnStub,+ sinon.match('Update available: ' + VERSION + ' -> 99.9.9'),);- assert.ok(spawnStub.notCalled);+ sinon.assert.notCalled(spawnStub);});it('does not notify if incoming version is older than current version', async () => {@@ -88,8 +87,8 @@ describe('checkForUpdates', () => {await checkForUpdates('Run `npm update` to update.');- assert.ok(warnStub.notCalled);- assert.ok(spawnStub.notCalled);+ sinon.assert.notCalled(warnStub);+ sinon.assert.notCalled(spawnStub);});it('does not spawn fetch process if cache is fresh', async () => {@@ -107,7 +106,7 @@ describe('checkForUpdates', () => {await checkForUpdates('Run `npm update` to update.');- assert.ok(spawnStub.notCalled);+ sinon.assert.notCalled(spawnStub);});it('spawns detached process if cache is stale', async () => {@@ -131,7 +130,7 @@ describe('checkForUpdates', () => {await checkForUpdates('Run `npm update` to update.');- assert.ok(spawnStub.calledOnce);+ sinon.assert.calledOnce(spawnStub);assert.strictEqual(spawnStub.firstCall.args[0], process.execPath);assert.ok(spawnStub.firstCall.args[1][0]?.includes('check-latest-version.js'),@@ -139,7 +138,7 @@ describe('checkForUpdates', () => {assert.ok(spawnStub.firstCall.args[1][1]?.includes('latest.json'));assert.strictEqual(spawnStub.firstCall.args[2]?.detached, true);assert.strictEqual(spawnStub.firstCall.args[2]?.windowsHide, true);- assert.ok(unrefSpy.calledOnce);+ sinon.assert.calledOnce(unrefSpy);});it('spawns detached process if cache is missing', async () => {@@ -156,7 +155,7 @@ describe('checkForUpdates', () => {await checkForUpdates('Run `npm update` to update.');- assert.ok(spawnStub.calledOnce);+ sinon.assert.calledOnce(spawnStub);assert.strictEqual(spawnStub.firstCall.args[0], process.execPath);assert.ok(spawnStub.firstCall.args[1][0]?.includes('check-latest-version.js'),@@ -164,6 +163,6 @@ describe('checkForUpdates', () => {assert.ok(spawnStub.firstCall.args[1][1]?.includes('latest.json'));assert.strictEqual(spawnStub.firstCall.args[2]?.detached, true);assert.strictEqual(spawnStub.firstCall.args[2]?.windowsHide, true);- assert.ok(unrefSpy.calledOnce);+ sinon.assert.calledOnce(unrefSpy);});});