From 326adaf65094477536136b4cadb4a0cd2fcea8ca Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Mon, 25 Nov 2024 12:53:38 +1300 Subject: [PATCH] test: Use mock directly (#1146) #### Motivation Simplify test --- .../basemaps-github/__test__/create-pr-handler.test.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/commands/basemaps-github/__test__/create-pr-handler.test.ts b/src/commands/basemaps-github/__test__/create-pr-handler.test.ts index 4c8869ed..2b97626a 100644 --- a/src/commands/basemaps-github/__test__/create-pr-handler.test.ts +++ b/src/commands/basemaps-github/__test__/create-pr-handler.test.ts @@ -55,10 +55,7 @@ await it('basemapsCreatePullRequest.handler should handle S3 target', async (t) t.mock.method(GithubApi.prototype, 'createBlob', () => {}); t.mock.method(GithubApi.prototype, 'createCommit', () => {}); t.mock.method(GithubApi.prototype, 'updateBranch', () => {}); - let createPullRequestCalled = false; - t.mock.method(GithubApi.prototype, 'createPullRequest', () => { - createPullRequestCalled = true; - }); + const createPullRequestMock = t.mock.method(GithubApi.prototype, 'createPullRequest', () => {}); const targetUrlsString = JSON.stringify([targetUrl]); const result = await basemapsCreatePullRequest.handler({ @@ -72,5 +69,5 @@ await it('basemapsCreatePullRequest.handler should handle S3 target', async (t) ticket: 'any ticket', }); assert.equal(result, undefined); - assert.ok(createPullRequestCalled); + assert.equal(createPullRequestMock.mock.callCount(), 1); });