From 75ef080fd5cb9608abe82cfaaa3c66eab24da96a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 4 Sep 2022 18:47:10 +0000 Subject: [PATCH 1/2] chore(deps): update dependency eslint-plugin-jest to v27 --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 7050e4b9ed..4c14839e4a 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "eslint-plugin-check-file": "1.2.2", "eslint-plugin-etc": "2.0.2", "eslint-plugin-import": "2.26.0", - "eslint-plugin-jest": "26.9.0", + "eslint-plugin-jest": "27.0.0", "eslint-plugin-jsx-a11y": "6.6.1", "eslint-plugin-n": "15.2.5", "eslint-plugin-node": "11.1.0", diff --git a/yarn.lock b/yarn.lock index 20889802d8..b42462799f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8613,10 +8613,10 @@ eslint-plugin-import@2.26.0: resolve "^1.22.0" tsconfig-paths "^3.14.1" -eslint-plugin-jest@26.9.0: - version "26.9.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-26.9.0.tgz#7931c31000b1c19e57dbfb71bbf71b817d1bf949" - integrity sha512-TWJxWGp1J628gxh2KhaH1H1paEdgE2J61BBF1I59c6xWeL5+D1BzMxGDN/nXAfX+aSkR5u80K+XhskK6Gwq9ng== +eslint-plugin-jest@27.0.0: + version "27.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-27.0.0.tgz#fafe827d6be5c1172068b6ad85f0faa4a27cbc7e" + integrity sha512-z+xyBosph1kSffGEbsDz4EgdzRnpdKzrPHgVtiQ9hcZsTKl8EOo6yLhNn55tGfJSEmJdEVqpXv1g+ZmTbT9rEQ== dependencies: "@typescript-eslint/utils" "^5.10.0" From efe6b4cf37d0ad4ced80d8d25949d1fa6a7226f3 Mon Sep 17 00:00:00 2001 From: Matt Seddon Date: Mon, 5 Sep 2022 06:01:42 +1000 Subject: [PATCH 2/2] fix new lint issues --- extension/src/cli/dvc/executor.test.ts | 56 ++--- extension/src/cli/dvc/index.test.ts | 4 +- extension/src/cli/dvc/reader.test.ts | 12 +- extension/src/cli/dvc/version.test.ts | 20 +- extension/src/cli/git/executor.test.ts | 10 +- extension/src/common/logger.test.ts | 8 +- .../src/experiments/columns/quickPick.test.ts | 6 +- .../src/experiments/columns/tree.test.ts | 6 +- .../model/filterBy/quickPick.test.ts | 8 +- .../model/modify/quickPick.test.ts | 10 +- .../src/experiments/model/quickPick.test.ts | 10 +- .../model/sortBy/quickPick.test.ts | 12 +- extension/src/experiments/quickPick.test.ts | 2 +- extension/src/experiments/toast.test.ts | 10 +- extension/src/experiments/workspace.test.ts | 72 +++--- extension/src/fileSystem/tree.test.ts | 34 +-- extension/src/fileSystem/watcher.test.ts | 2 +- extension/src/fileSystem/workspace.test.ts | 14 +- .../src/path/selection/quickPick.test.ts | 14 +- extension/src/plots/model/index.test.ts | 2 +- extension/src/python/index.test.ts | 16 +- .../src/repository/commands/index.test.ts | 4 +- .../repository/scmDecorationProvider.test.ts | 6 +- extension/src/setup.test.ts | 218 ++++++++++-------- extension/src/telemetry/index.test.ts | 14 +- extension/src/telemetry/uuid.test.ts | 34 +-- extension/src/util/disposable.test.ts | 4 +- extension/src/vscode/context.test.ts | 2 +- extension/src/vscode/inputBox.test.ts | 4 +- extension/src/vscode/modal.test.ts | 4 +- extension/src/vscode/quickPick.test.ts | 8 +- extension/src/vscode/recommend.test.ts | 12 +- extension/src/vscode/resourcePicker.test.ts | 4 +- extension/src/vscode/toast.test.ts | 26 ++- extension/src/vscode/walkthrough.test.ts | 26 +-- .../src/experiments/components/App.test.tsx | 34 +-- .../components/table/Table.test.tsx | 10 +- webview/src/plots/components/App.test.tsx | 36 +-- .../comparisonTable/ComparisonTable.test.tsx | 16 +- .../components/copyButton/CopyButton.test.tsx | 4 +- 40 files changed, 418 insertions(+), 376 deletions(-) diff --git a/extension/src/cli/dvc/executor.test.ts b/extension/src/cli/dvc/executor.test.ts index 78d6ba92c9..ea3ffda21a 100644 --- a/extension/src/cli/dvc/executor.test.ts +++ b/extension/src/cli/dvc/executor.test.ts @@ -80,7 +80,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.add(cwd, relPath) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['add', relPath], cwd, env: mockedEnv, @@ -98,7 +98,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.checkout(fsPath) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['checkout'], cwd: fsPath, env: mockedEnv, @@ -114,7 +114,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.checkout(fsPath, Flag.FORCE) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['checkout', '-f'], cwd: fsPath, env: mockedEnv, @@ -133,7 +133,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.checkout(cwd, relPath) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['checkout', relPath], cwd, env: mockedEnv, @@ -152,7 +152,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.checkout(cwd, relPath, Flag.FORCE) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['checkout', relPath, '-f'], cwd, env: mockedEnv, @@ -170,7 +170,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.commit(cwd) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['commit'], cwd, env: mockedEnv, @@ -186,7 +186,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.commit(cwd, Flag.FORCE) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['commit', '-f'], cwd, env: mockedEnv, @@ -208,7 +208,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.commit(cwd, relPath) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['commit', relPath], cwd, env: mockedEnv, @@ -230,7 +230,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.commit(cwd, relPath, Flag.FORCE) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['commit', relPath, '-f'], cwd, env: mockedEnv, @@ -248,7 +248,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.experimentApply(cwd, 'exp-test') expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['exp', 'apply', 'exp-test'], cwd, env: mockedEnv, @@ -273,7 +273,7 @@ describe('CliExecutor', () => { ) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['exp', 'branch', 'exp-0898f', 'some-branch'], cwd, env: mockedEnv, @@ -298,7 +298,7 @@ describe('CliExecutor', () => { ) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['exp', 'gc', '-f', '--workspace', '--queued'], cwd, env: mockedEnv, @@ -316,7 +316,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.experimentRemove(cwd, 'exp-dfd12') expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['exp', 'remove', 'exp-dfd12'], cwd, env: mockedEnv, @@ -334,7 +334,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.experimentRemoveQueue(cwd) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['exp', 'remove', '--queue'], cwd, env: mockedEnv, @@ -352,7 +352,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.experimentRunQueue(cwd) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['exp', 'run', '--queue'], cwd, env: mockedEnv, @@ -387,7 +387,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.init(fsPath) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['init', '--subdir'], cwd: fsPath, env: mockedEnv, @@ -411,7 +411,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.move(cwd, target, destination) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['move', target, destination], cwd, env: mockedEnv, @@ -430,7 +430,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.pull(cwd) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['pull'], cwd, env: mockedEnv, @@ -447,7 +447,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.pull(cwd, Flag.FORCE) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['pull', '-f'], cwd, env: mockedEnv, @@ -465,7 +465,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.pull(cwd, relPath) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['pull', relPath], cwd, env: mockedEnv, @@ -483,7 +483,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.pull(cwd, relPath, Flag.FORCE) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['pull', relPath, '-f'], cwd, env: mockedEnv, @@ -502,7 +502,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.push(cwd) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['push'], cwd, env: mockedEnv, @@ -518,7 +518,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.push(cwd, Flag.FORCE) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['push', '-f'], cwd, env: mockedEnv, @@ -536,7 +536,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.push(cwd, relPath) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['push', relPath], cwd, env: mockedEnv, @@ -554,7 +554,7 @@ describe('CliExecutor', () => { const output = await dvcExecutor.push(cwd, relPath, Flag.FORCE) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['push', relPath, '-f'], cwd, env: mockedEnv, @@ -575,15 +575,15 @@ describe('CliExecutor', () => { const output = await dvcExecutor.remove(cwd, relPath) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['remove', relPath], cwd, env: mockedEnv, executable: 'dvc' }) - expect(mockedSetContextValue).toBeCalledTimes(2) - expect(mockedSetContextValue).toBeCalledWith( + expect(mockedSetContextValue).toHaveBeenCalledTimes(2) + expect(mockedSetContextValue).toHaveBeenCalledWith( 'dvc.scm.command.running', true ) diff --git a/extension/src/cli/dvc/index.test.ts b/extension/src/cli/dvc/index.test.ts index acf54db211..c99830e64b 100644 --- a/extension/src/cli/dvc/index.test.ts +++ b/extension/src/cli/dvc/index.test.ts @@ -82,7 +82,7 @@ describe('executeDvcProcess', () => { await cli.executeDvcProcess(cwd, ...args) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args, cwd, env: { ...processEnv, DVCLIVE_OPEN: 'false', DVC_NO_ANALYTICS: 'true' }, @@ -121,7 +121,7 @@ describe('executeDvcProcess', () => { await expect(cli.executeDvcProcess(cwd, ...args)).rejects.toThrow() - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args, cwd, env: { diff --git a/extension/src/cli/dvc/reader.test.ts b/extension/src/cli/dvc/reader.test.ts index 3ab73992e9..255d79edd1 100644 --- a/extension/src/cli/dvc/reader.test.ts +++ b/extension/src/cli/dvc/reader.test.ts @@ -71,7 +71,7 @@ describe('CliReader', () => { const cliOutput = await dvcReader.expShow(cwd) expect(cliOutput).toStrictEqual(expShowFixture) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['exp', 'show', JSON_FLAG], cwd, env: mockedEnv, @@ -132,7 +132,7 @@ describe('CliReader', () => { expect(statusOutput).toStrictEqual(cliOutput) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['data', 'status', '--granular', '--unchanged', JSON_FLAG], cwd, env: mockedEnv, @@ -159,7 +159,7 @@ describe('CliReader', () => { const plots = await dvcReader.plotsDiff(cwd, 'HEAD') expect(plots).toStrictEqual(plotsDiffFixture) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: [ 'plots', 'diff', @@ -183,7 +183,7 @@ describe('CliReader', () => { mockedCreateProcess.mockReturnValueOnce(getMockedProcess(stdout)) const relativeRoot = await dvcReader.root(cwd) expect(relativeRoot).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['root'], cwd, env: mockedEnv, @@ -201,7 +201,7 @@ describe('CliReader', () => { const relativeRoot = await dvcReader.root(cwd) expect(relativeRoot).toBeUndefined() - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['root'], cwd, env: mockedEnv, @@ -218,7 +218,7 @@ describe('CliReader', () => { const output = await dvcReader.version(cwd) expect(output).toStrictEqual(stdout) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['--version'], cwd, env: mockedEnv, diff --git a/extension/src/cli/dvc/version.test.ts b/extension/src/cli/dvc/version.test.ts index cf0d067225..06228b1f46 100644 --- a/extension/src/cli/dvc/version.test.ts +++ b/extension/src/cli/dvc/version.test.ts @@ -61,7 +61,7 @@ describe('isVersionCompatible', () => { const isCompatible = isVersionCompatible(MIN_CLI_VERSION) expect(isCompatible).toBe(true) - expect(mockedWarnWithOptions).not.toBeCalled() + expect(mockedWarnWithOptions).not.toHaveBeenCalled() }) it('should be compatible and not send a toast for a version with the same minor and higher patch as the min compatible version', () => { @@ -72,7 +72,7 @@ describe('isVersionCompatible', () => { ) expect(isCompatible).toBe(true) - expect(mockedWarnWithOptions).not.toBeCalled() + expect(mockedWarnWithOptions).not.toHaveBeenCalled() }) it('should be compatible and not send a toast for a version with the same minor and higher patch as the latest tested version', () => { @@ -85,7 +85,7 @@ describe('isVersionCompatible', () => { ) expect(isCompatible).toBe(true) - expect(mockedWarnWithOptions).not.toBeCalled() + expect(mockedWarnWithOptions).not.toHaveBeenCalled() }) it('should be compatible and not send a toast for a major and minor version in between the min compatible and the latest tested', () => { @@ -98,7 +98,7 @@ describe('isVersionCompatible', () => { ) expect(isCompatible).toBe(true) - expect(mockedWarnWithOptions).not.toBeCalled() + expect(mockedWarnWithOptions).not.toHaveBeenCalled() }) it('should be compatible and send a toast for a version with a minor higher as the latest tested minor and any patch', () => { @@ -122,7 +122,7 @@ describe('isVersionCompatible', () => { ) expect(isCompatible).toBe(true) - expect(mockedWarnWithOptions).toBeCalledTimes(3) + expect(mockedWarnWithOptions).toHaveBeenCalledTimes(3) }) it('should not be compatible and send a toast message if the provided version is a patch version before the minimum expected version', () => { @@ -133,7 +133,7 @@ describe('isVersionCompatible', () => { ) expect(isCompatible).toBe(false) - expect(mockedWarnWithOptions).toBeCalledTimes(1) + expect(mockedWarnWithOptions).toHaveBeenCalledTimes(1) }) it('should not be compatible and send a toast message if the provided minor version is before the minimum expected version', () => { @@ -144,7 +144,7 @@ describe('isVersionCompatible', () => { ) expect(isCompatible).toBe(false) - expect(mockedWarnWithOptions).toBeCalledTimes(1) + expect(mockedWarnWithOptions).toHaveBeenCalledTimes(1) }) it('should not be compatible and send a toast message if the provided major version is before the minimum expected version', () => { @@ -155,7 +155,7 @@ describe('isVersionCompatible', () => { ) expect(isCompatible).toBe(false) - expect(mockedWarnWithOptions).toBeCalledTimes(1) + expect(mockedWarnWithOptions).toHaveBeenCalledTimes(1) }) it('should not be compatible and send a toast message if the provided major version is above the expected major version', () => { @@ -164,7 +164,7 @@ describe('isVersionCompatible', () => { const isCompatible = isVersionCompatible('3.0.0') expect(isCompatible).toBe(false) - expect(mockedWarnWithOptions).toBeCalledTimes(1) + expect(mockedWarnWithOptions).toHaveBeenCalledTimes(1) }) it('should not be compatible and send a toast message if the provided version is malformed', () => { @@ -176,6 +176,6 @@ describe('isVersionCompatible', () => { isCompatible = isVersionCompatible('1,2,3') expect(isCompatible).toBe(false) - expect(mockedWarnWithOptions).toBeCalledTimes(2) + expect(mockedWarnWithOptions).toHaveBeenCalledTimes(2) }) }) diff --git a/extension/src/cli/git/executor.test.ts b/extension/src/cli/git/executor.test.ts index eb1e19744f..5f5101c6c2 100644 --- a/extension/src/cli/git/executor.test.ts +++ b/extension/src/cli/git/executor.test.ts @@ -49,7 +49,7 @@ describe('GitExecutor', () => { ) await gitExecutor.pushBranch(cwd, branchName) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['push', '--set-upstream', 'origin', branchName], cwd, executable: 'git' @@ -63,7 +63,7 @@ describe('GitExecutor', () => { ) await gitExecutor.pushBranch(cwd) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['push', '--set-upstream', 'origin', 'HEAD'], cwd, executable: 'git' @@ -83,13 +83,13 @@ describe('GitExecutor', () => { ) await gitExecutor.stageAndCommit(cwd, message) - expect(mockedCreateProcess).toBeCalledTimes(3) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledTimes(3) + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['add', '.'], cwd, executable: 'git' }) - expect(mockedCreateProcess).toBeCalledWith({ + expect(mockedCreateProcess).toHaveBeenCalledWith({ args: ['commit', '-m', message], cwd, executable: 'git' diff --git a/extension/src/common/logger.test.ts b/extension/src/common/logger.test.ts index c57730abb8..07037d6c83 100644 --- a/extension/src/common/logger.test.ts +++ b/extension/src/common/logger.test.ts @@ -6,7 +6,7 @@ describe('Logger', () => { const error = 'I wrong' const logSpy = jest.spyOn(console, 'error').mockReturnValueOnce(undefined) Logger.error(error) - expect(logSpy).toBeCalledWith(error) + expect(logSpy).toHaveBeenCalledWith(error) }) }) @@ -15,7 +15,7 @@ describe('Logger', () => { const warn = 'I may be wrong' const logSpy = jest.spyOn(console, 'warn').mockReturnValueOnce(undefined) Logger.warn(warn) - expect(logSpy).toBeCalledWith(warn) + expect(logSpy).toHaveBeenCalledWith(warn) }) }) @@ -24,7 +24,7 @@ describe('Logger', () => { const info = 'I am information' const logSpy = jest.spyOn(console, 'info').mockReturnValueOnce(undefined) Logger.info(info) - expect(logSpy).toBeCalledWith(info) + expect(logSpy).toHaveBeenCalledWith(info) }) }) @@ -33,7 +33,7 @@ describe('Logger', () => { const log = 'I am probably something that helps you debug' const logSpy = jest.spyOn(console, 'log').mockReturnValueOnce(undefined) Logger.log(log) - expect(logSpy).toBeCalledWith(log) + expect(logSpy).toHaveBeenCalledWith(log) }) }) }) diff --git a/extension/src/experiments/columns/quickPick.test.ts b/extension/src/experiments/columns/quickPick.test.ts index e8f2fb5b8c..6472840a9e 100644 --- a/extension/src/experiments/columns/quickPick.test.ts +++ b/extension/src/experiments/columns/quickPick.test.ts @@ -39,14 +39,14 @@ describe('pickFromColumnLikes', () => { title: "can't pick from no columns" as Title }) expect(picked).toBeUndefined() - expect(mockedShowError).toBeCalledTimes(1) - expect(mockedQuickPickValue).not.toBeCalled() + expect(mockedShowError).toHaveBeenCalledTimes(1) + expect(mockedQuickPickValue).not.toHaveBeenCalled() }) it('should invoke a QuickPick with the correct options', async () => { const title = 'Test title' as Title await pickFromColumnLikes(exampleColumns, { title }) - expect(mockedQuickPickValue).toBeCalledWith( + expect(mockedQuickPickValue).toHaveBeenCalledWith( [ { description: epochsParamPath, diff --git a/extension/src/experiments/columns/tree.test.ts b/extension/src/experiments/columns/tree.test.ts index 32b2467db8..aaa684323a 100644 --- a/extension/src/experiments/columns/tree.test.ts +++ b/extension/src/experiments/columns/tree.test.ts @@ -426,7 +426,7 @@ describe('ExperimentsColumnsTree', () => { const treeItem = experimentsColumnsTree.getTreeItem(mockedDvcRoot) - expect(mockedTreeItem).toBeCalledTimes(1) + expect(mockedTreeItem).toHaveBeenCalledTimes(1) expect(treeItem).toStrictEqual({ ...mockedItem }) @@ -459,7 +459,7 @@ describe('ExperimentsColumnsTree', () => { const treeItem = experimentsColumnsTree.getTreeItem(columnsItem) - expect(mockedTreeItem).toBeCalledTimes(1) + expect(mockedTreeItem).toHaveBeenCalledTimes(1) expect(treeItem).toStrictEqual({ collapsibleState: 1, command: { @@ -499,7 +499,7 @@ describe('ExperimentsColumnsTree', () => { const treeItem = experimentsColumnsTree.getTreeItem(columnsItem) - expect(mockedTreeItem).toBeCalledTimes(1) + expect(mockedTreeItem).toHaveBeenCalledTimes(1) expect(treeItem).toStrictEqual({ collapsibleState: 0, command: { diff --git a/extension/src/experiments/model/filterBy/quickPick.test.ts b/extension/src/experiments/model/filterBy/quickPick.test.ts index 738e0662d9..60eac846d1 100644 --- a/extension/src/experiments/model/filterBy/quickPick.test.ts +++ b/extension/src/experiments/model/filterBy/quickPick.test.ts @@ -76,7 +76,7 @@ describe('pickFilterToAdd', () => { mockedQuickPickValue.mockResolvedValueOnce(mixedParam) mockedQuickPickValue.mockResolvedValueOnce(undefined) await pickFilterToAdd(params) - expect(mockedQuickPickValue).toBeCalledWith( + expect(mockedQuickPickValue).toHaveBeenCalledWith( OPERATORS.filter( ({ types }) => !(types.length === 1 && types[0] === ColumnType.TIMESTAMP) @@ -106,13 +106,13 @@ describe('pickFilterToAdd', () => { path: boolParam.path, value: undefined }) - expect(mockedQuickPickValue).toBeCalledWith( + expect(mockedQuickPickValue).toHaveBeenCalledWith( OPERATORS.filter(operator => operator.types.includes('boolean')), { title: Title.SELECT_OPERATOR } ) - expect(mockedGetInput).not.toBeCalled() + expect(mockedGetInput).not.toHaveBeenCalled() }) it('should return a filter definition if all of the steps are completed', async () => { @@ -126,7 +126,7 @@ describe('pickFilterToAdd', () => { path: epochsParam.path, value: '5' }) - expect(mockedQuickPickValue).toBeCalledWith( + expect(mockedQuickPickValue).toHaveBeenCalledWith( OPERATORS.filter(operator => operator.types.includes('number')), { title: Title.SELECT_OPERATOR diff --git a/extension/src/experiments/model/modify/quickPick.test.ts b/extension/src/experiments/model/modify/quickPick.test.ts index 044e22c44d..177325499b 100644 --- a/extension/src/experiments/model/modify/quickPick.test.ts +++ b/extension/src/experiments/model/modify/quickPick.test.ts @@ -21,7 +21,7 @@ describe('pickAndModifyParams', () => { ]) expect(paramsToQueue).toBeUndefined() - expect(mockedGetInput).not.toBeCalled() + expect(mockedGetInput).not.toHaveBeenCalled() }) it('should return early if the user exits from the input box', async () => { @@ -41,7 +41,7 @@ describe('pickAndModifyParams', () => { ]) expect(paramsToQueue).toBeUndefined() - expect(mockedGetInput).toBeCalledTimes(2) + expect(mockedGetInput).toHaveBeenCalledTimes(2) }) it('should convert any selected params into the required format', async () => { @@ -64,8 +64,8 @@ describe('pickAndModifyParams', () => { ...initialUserResponse ]) - expect(mockedGetInput).toBeCalledTimes(3) - expect(mockedGetInput).toBeCalledWith( + expect(mockedGetInput).toHaveBeenCalledTimes(3) + expect(mockedGetInput).toHaveBeenCalledWith( 'Enter a Value for params.yaml:code_names', '[0,1,2]' ) @@ -80,6 +80,6 @@ describe('pickAndModifyParams', () => { '-S', [unchanged.path, unchanged.value].join('=') ]) - expect(mockedGetInput).toBeCalledTimes(3) + expect(mockedGetInput).toHaveBeenCalledTimes(3) }) }) diff --git a/extension/src/experiments/model/quickPick.test.ts b/extension/src/experiments/model/quickPick.test.ts index e549f4d9f0..c0d07bf62e 100644 --- a/extension/src/experiments/model/quickPick.test.ts +++ b/extension/src/experiments/model/quickPick.test.ts @@ -18,7 +18,7 @@ describe('pickExperiments', () => { it('should return early given no experiments', async () => { const undef = await pickExperiments([], false) expect(undef).toBeUndefined() - expect(mockedQuickPickLimitedValues).not.toBeCalled() + expect(mockedQuickPickLimitedValues).not.toHaveBeenCalled() }) it('should return the selected experiment', async () => { @@ -37,8 +37,8 @@ describe('pickExperiments', () => { const picked = await pickExperiments(mockedExperiments, false) expect(picked).toStrictEqual([selectedExperiment]) - expect(mockedQuickPickLimitedValues).toBeCalledTimes(1) - expect(mockedQuickPickLimitedValues).toBeCalledWith( + expect(mockedQuickPickLimitedValues).toHaveBeenCalledTimes(1) + expect(mockedQuickPickLimitedValues).toHaveBeenCalledWith( [ { description: '[exp-123]', @@ -126,8 +126,8 @@ describe('pickExperiments', () => { }) expect(picked).toStrictEqual([selectedExperiment, selectedCheckpoint]) - expect(mockedQuickPickLimitedValues).toBeCalledTimes(1) - expect(mockedQuickPickLimitedValues).toBeCalledWith( + expect(mockedQuickPickLimitedValues).toHaveBeenCalledTimes(1) + expect(mockedQuickPickLimitedValues).toHaveBeenCalledWith( [ getExpectedItem(mockedWorkspace), getExpectedItem(mockedBranch), diff --git a/extension/src/experiments/model/sortBy/quickPick.test.ts b/extension/src/experiments/model/sortBy/quickPick.test.ts index 238bf39fb9..668897f8a4 100644 --- a/extension/src/experiments/model/sortBy/quickPick.test.ts +++ b/extension/src/experiments/model/sortBy/quickPick.test.ts @@ -40,29 +40,29 @@ const exampleColumns = [epochsParam, paramsYamlParam] describe('pickSortToAdd', () => { it('should not invoke a quickPick if an empty array', async () => { const resolvedPromise = await pickSortToAdd([]) - expect(mockedQuickPickValue).not.toBeCalled() + expect(mockedQuickPickValue).not.toHaveBeenCalled() expect(resolvedPromise).toBe(undefined) }) it('should resolve with no value if canceled at param or metric select', async () => { mockedQuickPickValue.mockResolvedValueOnce(undefined) expect(await pickSortToAdd(exampleColumns)).toBe(undefined) - expect(mockedQuickPickValue).toBeCalledTimes(1) + expect(mockedQuickPickValue).toHaveBeenCalledTimes(1) }) it('should resolve with no value if canceled at order select', async () => { mockedQuickPickValue.mockResolvedValueOnce(epochsParam) mockedQuickPickValue.mockResolvedValueOnce(undefined) expect(await pickSortToAdd(exampleColumns)).toBe(undefined) - expect(mockedQuickPickValue).toBeCalledTimes(2) + expect(mockedQuickPickValue).toHaveBeenCalledTimes(2) }) it('should invoke a descending sort with the expected quickPick calls', async () => { mockedQuickPickValue.mockResolvedValueOnce(epochsParam) mockedQuickPickValue.mockResolvedValueOnce(false) const resolvedPromise = await pickSortToAdd(exampleColumns) - expect(mockedQuickPickValue).toBeCalledTimes(2) - expect(mockedQuickPickValue).toBeCalledWith( + expect(mockedQuickPickValue).toHaveBeenCalledTimes(2) + expect(mockedQuickPickValue).toHaveBeenCalledWith( [ { label: 'Ascending', value: false }, { label: 'Descending', value: true } @@ -79,7 +79,7 @@ describe('pickSortToAdd', () => { mockedQuickPickValue.mockResolvedValueOnce(paramsYamlParam) mockedQuickPickValue.mockResolvedValueOnce(false) const resolvedPromise = await pickSortToAdd(exampleColumns) - expect(mockedQuickPickValue).toBeCalledTimes(2) + expect(mockedQuickPickValue).toHaveBeenCalledTimes(2) expect(resolvedPromise).toStrictEqual({ descending: false, path: paramsYamlPath diff --git a/extension/src/experiments/quickPick.test.ts b/extension/src/experiments/quickPick.test.ts index b1b10df3ac..9c7307679e 100644 --- a/extension/src/experiments/quickPick.test.ts +++ b/extension/src/experiments/quickPick.test.ts @@ -113,7 +113,7 @@ describe('pickExperiment', () => { describe('pickGarbageCollectionFlags', () => { it('should invoke a QuickPick with the correct options', async () => { await pickGarbageCollectionFlags() - expect(mockedQuickPickManyValues).toBeCalledWith( + expect(mockedQuickPickManyValues).toHaveBeenCalledWith( [ { detail: 'Preserve experiments derived from the current workspace', diff --git a/extension/src/experiments/toast.test.ts b/extension/src/experiments/toast.test.ts index e5304395a3..267c16df4f 100644 --- a/extension/src/experiments/toast.test.ts +++ b/extension/src/experiments/toast.test.ts @@ -25,9 +25,9 @@ describe('askToDisableAutoApplyFilters', () => { Response.TURN_OFF ) expect(response).toBeUndefined() - expect(mockedGetConfigValue).toBeCalledTimes(1) - expect(mockedSetUserConfigValue).not.toBeCalled() - expect(mockedWarnWithOptions).not.toBeCalled() + expect(mockedGetConfigValue).toHaveBeenCalledTimes(1) + expect(mockedSetUserConfigValue).not.toHaveBeenCalled() + expect(mockedWarnWithOptions).not.toHaveBeenCalled() }) it("should set the appropriate config option when the user response with Don't Show Again", async () => { @@ -39,7 +39,7 @@ describe('askToDisableAutoApplyFilters', () => { Response.TURN_OFF ) expect(response).toStrictEqual(Response.NEVER) - expect(mockedSetUserConfigValue).toBeCalledTimes(1) + expect(mockedSetUserConfigValue).toHaveBeenCalledTimes(1) }) it('should return cancel when the user dismisses the toast', async () => { @@ -51,6 +51,6 @@ describe('askToDisableAutoApplyFilters', () => { Response.TURN_OFF ) expect(response).toStrictEqual(Response.CANCEL) - expect(mockedSetUserConfigValue).not.toBeCalled() + expect(mockedSetUserConfigValue).not.toHaveBeenCalled() }) }) diff --git a/extension/src/experiments/workspace.test.ts b/extension/src/experiments/workspace.test.ts index b6e07a26bc..d898a82b53 100644 --- a/extension/src/experiments/workspace.test.ts +++ b/extension/src/experiments/workspace.test.ts @@ -81,9 +81,9 @@ describe('Experiments', () => { await workspaceExperiments.getCwdThenReport(mockedCommandId) - expect(mockedQuickPickOne).toBeCalledTimes(1) - expect(mockedExpFunc).toBeCalledTimes(1) - expect(mockedExpFunc).toBeCalledWith(mockedDvcRoot) + expect(mockedQuickPickOne).toHaveBeenCalledTimes(1) + expect(mockedExpFunc).toHaveBeenCalledTimes(1) + expect(mockedExpFunc).toHaveBeenCalledWith(mockedDvcRoot) }) it('should not call the function if a project is not picked', async () => { @@ -91,8 +91,8 @@ describe('Experiments', () => { await workspaceExperiments.getCwdThenReport(mockedCommandId) - expect(mockedQuickPickOne).toBeCalledTimes(1) - expect(mockedExpFunc).not.toBeCalled() + expect(mockedQuickPickOne).toHaveBeenCalledTimes(1) + expect(mockedExpFunc).not.toHaveBeenCalled() }) }) @@ -102,10 +102,10 @@ describe('Experiments', () => { await workspaceExperiments.pauseUpdatesThenRun(mockedFunc) - expect(mockedUpdatesPaused.fire).toBeCalledTimes(2) - expect(mockedUpdatesPaused.fire).toBeCalledWith(true) + expect(mockedUpdatesPaused.fire).toHaveBeenCalledTimes(2) + expect(mockedUpdatesPaused.fire).toHaveBeenCalledWith(true) expect(mockedUpdatesPaused.fire).toHaveBeenLastCalledWith(false) - expect(mockedFunc).toBeCalledTimes(1) + expect(mockedFunc).toHaveBeenCalledTimes(1) }) }) @@ -119,10 +119,10 @@ describe('Experiments', () => { await workspaceExperiments.getCwdAndExpNameThenRun(mockedCommandId) - expect(mockedQuickPickOne).toBeCalledTimes(1) - expect(mockedPickCurrentExperiment).toBeCalledTimes(1) - expect(mockedExpFunc).toBeCalledTimes(1) - expect(mockedExpFunc).toBeCalledWith(mockedDvcRoot, 'exp-123') + expect(mockedQuickPickOne).toHaveBeenCalledTimes(1) + expect(mockedPickCurrentExperiment).toHaveBeenCalledTimes(1) + expect(mockedExpFunc).toHaveBeenCalledTimes(1) + expect(mockedExpFunc).toHaveBeenCalledWith(mockedDvcRoot, 'exp-123') }) it('should not call the function if a project is not picked', async () => { @@ -130,8 +130,8 @@ describe('Experiments', () => { await workspaceExperiments.getCwdAndExpNameThenRun(mockedCommandId) - expect(mockedQuickPickOne).toBeCalledTimes(1) - expect(mockedExpFunc).not.toBeCalled() + expect(mockedQuickPickOne).toHaveBeenCalledTimes(1) + expect(mockedExpFunc).not.toHaveBeenCalled() }) }) @@ -148,10 +148,10 @@ describe('Experiments', () => { mockedQuickPick ) - expect(mockedQuickPickOne).toBeCalledTimes(1) - expect(mockedQuickPick).toBeCalledTimes(1) - expect(mockedExpFunc).toBeCalledTimes(1) - expect(mockedExpFunc).toBeCalledWith( + expect(mockedQuickPickOne).toHaveBeenCalledTimes(1) + expect(mockedQuickPick).toHaveBeenCalledTimes(1) + expect(mockedExpFunc).toHaveBeenCalledTimes(1) + expect(mockedExpFunc).toHaveBeenCalledWith( mockedDvcRoot, ...mockedPickedOptions ) @@ -166,9 +166,9 @@ describe('Experiments', () => { mockedQuickPick ) - expect(mockedQuickPickOne).toBeCalledTimes(1) - expect(mockedQuickPick).not.toBeCalled() - expect(mockedExpFunc).not.toBeCalled() + expect(mockedQuickPickOne).toHaveBeenCalledTimes(1) + expect(mockedQuickPick).not.toHaveBeenCalled() + expect(mockedExpFunc).not.toHaveBeenCalled() }) it('should not call the function if quick picks are not provided', async () => { @@ -180,9 +180,9 @@ describe('Experiments', () => { mockedQuickPick ) - expect(mockedQuickPickOne).toBeCalledTimes(1) - expect(mockedQuickPick).toBeCalledTimes(1) - expect(mockedExpFunc).not.toBeCalled() + expect(mockedQuickPickOne).toHaveBeenCalledTimes(1) + expect(mockedQuickPick).toHaveBeenCalledTimes(1) + expect(mockedExpFunc).not.toHaveBeenCalled() }) }) @@ -201,10 +201,14 @@ describe('Experiments', () => { 'enter your password please' as Title ) - expect(mockedQuickPickOne).toBeCalledTimes(1) - expect(mockedPickCurrentExperiment).toBeCalledTimes(1) - expect(mockedExpFunc).toBeCalledTimes(1) - expect(mockedExpFunc).toBeCalledWith(mockedDvcRoot, 'exp-123', 'abc123') + expect(mockedQuickPickOne).toHaveBeenCalledTimes(1) + expect(mockedPickCurrentExperiment).toHaveBeenCalledTimes(1) + expect(mockedExpFunc).toHaveBeenCalledTimes(1) + expect(mockedExpFunc).toHaveBeenCalledWith( + mockedDvcRoot, + 'exp-123', + 'abc123' + ) }) it('should not call the function or ask for input if a project is not picked', async () => { @@ -216,9 +220,9 @@ describe('Experiments', () => { 'please name the branch' as Title ) - expect(mockedQuickPickOne).toBeCalledTimes(1) - expect(mockedGetInput).not.toBeCalled() - expect(mockedExpFunc).not.toBeCalled() + expect(mockedQuickPickOne).toHaveBeenCalledTimes(1) + expect(mockedGetInput).not.toHaveBeenCalled() + expect(mockedExpFunc).not.toHaveBeenCalled() }) it('should not call the function if user input is not provided', async () => { @@ -235,9 +239,9 @@ describe('Experiments', () => { 'please enter your bank account number and sort code' as Title ) - expect(mockedQuickPickOne).toBeCalledTimes(1) - expect(mockedGetInput).toBeCalledTimes(1) - expect(mockedExpFunc).not.toBeCalled() + expect(mockedQuickPickOne).toHaveBeenCalledTimes(1) + expect(mockedGetInput).toHaveBeenCalledTimes(1) + expect(mockedExpFunc).not.toHaveBeenCalled() }) }) }) diff --git a/extension/src/fileSystem/tree.test.ts b/extension/src/fileSystem/tree.test.ts index b21111d1c6..0bdff9af27 100644 --- a/extension/src/fileSystem/tree.test.ts +++ b/extension/src/fileSystem/tree.test.ts @@ -84,7 +84,7 @@ describe('TrackedTreeView', () => { ) trackedTreeView.initialize([dvcDemoPath]) - expect(mockedTreeDataChangedFire).toBeCalledTimes(1) + expect(mockedTreeDataChangedFire).toHaveBeenCalledTimes(1) }) }) @@ -115,8 +115,8 @@ describe('TrackedTreeView', () => { resourceUri: Uri.file(mockedOtherRoot) } ]) - expect(mockedGetRepository).toBeCalledTimes(0) - expect(mockedGetChildren).toBeCalledTimes(0) + expect(mockedGetRepository).toHaveBeenCalledTimes(0) + expect(mockedGetChildren).toHaveBeenCalledTimes(0) }) it('should return the single dvc root if it is nested', async () => { @@ -185,9 +185,9 @@ describe('TrackedTreeView', () => { expect( rootElements.map(({ resourceUri }) => basename(resourceUri.fsPath)) ).toStrictEqual(['data', 'logs', 'plots', 'model.pt']) - expect(mockedGetRepository).toBeCalledTimes(1) - expect(mockedGetRepository).toBeCalledWith(dvcDemoPath) - expect(mockedGetChildren).toBeCalledTimes(1) + expect(mockedGetRepository).toHaveBeenCalledTimes(1) + expect(mockedGetRepository).toHaveBeenCalledWith(dvcDemoPath) + expect(mockedGetChildren).toHaveBeenCalledTimes(1) }) it('should get the children for the provided element', async () => { @@ -222,9 +222,9 @@ describe('TrackedTreeView', () => { const rootElements = await trackedTreeView.getChildren() - expect(mockedGetRepository).toBeCalledTimes(1) - expect(mockedGetRepository).toBeCalledWith(dvcDemoPath) - expect(mockedGetChildren).toBeCalledWith(dvcDemoPath) + expect(mockedGetRepository).toHaveBeenCalledTimes(1) + expect(mockedGetRepository).toHaveBeenCalledWith(dvcDemoPath) + expect(mockedGetChildren).toHaveBeenCalledWith(dvcDemoPath) expect(rootElements).toStrictEqual(mockedRootItems) mockedGetRepository.mockClear() @@ -247,9 +247,9 @@ describe('TrackedTreeView', () => { resourceUri: data }) - expect(mockedGetRepository).toBeCalledTimes(1) - expect(mockedGetRepository).toBeCalledWith(dvcDemoPath) - expect(mockedGetChildren).toBeCalledWith(data.fsPath) + expect(mockedGetRepository).toHaveBeenCalledTimes(1) + expect(mockedGetRepository).toHaveBeenCalledWith(dvcDemoPath) + expect(mockedGetChildren).toHaveBeenCalledWith(data.fsPath) expect(child).toStrictEqual(mockedDirItems) }) }) @@ -277,7 +277,7 @@ describe('TrackedTreeView', () => { resourceUri: Uri.file(join(dvcDemoPath, 'data')) }) - expect(mockedTreeItem).toBeCalledTimes(1) + expect(mockedTreeItem).toHaveBeenCalledTimes(1) expect(treeItem).toStrictEqual({ ...mockedItem, contextValue: 'virtual' @@ -305,7 +305,7 @@ describe('TrackedTreeView', () => { resourceUri: log }) - expect(mockedTreeItem).toBeCalledTimes(1) + expect(mockedTreeItem).toHaveBeenCalledTimes(1) expect(treeItem).toStrictEqual({ ...mockedItem, contextValue: 'virtual' @@ -334,7 +334,7 @@ describe('TrackedTreeView', () => { resourceUri: Uri.file(join(dvcDemoPath, 'data')) }) - expect(mockedTreeItem).toBeCalledTimes(1) + expect(mockedTreeItem).toHaveBeenCalledTimes(1) expect(treeItem).toStrictEqual({ ...mockedItem, contextValue: 'dirData' @@ -364,7 +364,7 @@ describe('TrackedTreeView', () => { resourceUri: log }) - expect(mockedTreeItem).toBeCalledTimes(1) + expect(mockedTreeItem).toHaveBeenCalledTimes(1) expect(treeItem).toStrictEqual({ ...mockedItem, command: { @@ -405,7 +405,7 @@ describe('TrackedTreeView', () => { } } as PathItem) - expect(mockedTreeItem).toBeCalledTimes(1) + expect(mockedTreeItem).toHaveBeenCalledTimes(1) expect(treeItem).toStrictEqual({ ...mockedItem, command: { diff --git a/extension/src/fileSystem/watcher.test.ts b/extension/src/fileSystem/watcher.test.ts index a108c6eb0d..9886fb5bd3 100644 --- a/extension/src/fileSystem/watcher.test.ts +++ b/extension/src/fileSystem/watcher.test.ts @@ -96,7 +96,7 @@ describe('createFileSystemWatcher', () => { createFileSystemWatcher(file, mockedListener) - expect(mockedCreateFileSystemWatcher).toBeCalledWith(file) + expect(mockedCreateFileSystemWatcher).toHaveBeenCalledWith(file) }) it('should throw an error when given a directory path', () => { diff --git a/extension/src/fileSystem/workspace.test.ts b/extension/src/fileSystem/workspace.test.ts index 742f13427d..c1e54edc69 100644 --- a/extension/src/fileSystem/workspace.test.ts +++ b/extension/src/fileSystem/workspace.test.ts @@ -27,8 +27,10 @@ describe('deleteTarget', () => { const path = Uri.file(join('test', 'path')) const deleted = await deleteTarget(path) - expect(mockedWorkspaceEdit).toBeCalledTimes(1) - expect(mockedApplyEdit).toBeCalledWith({ deleteFile: mockedDeleteFile }) + expect(mockedWorkspaceEdit).toHaveBeenCalledTimes(1) + expect(mockedApplyEdit).toHaveBeenCalledWith({ + deleteFile: mockedDeleteFile + }) expect(deleted).toBe(true) }) }) @@ -47,12 +49,14 @@ describe('moveTargets', () => { const destination = Uri.file(join('other', 'folder')) const moved = await moveTargets([path], destination) - expect(mockedWorkspaceEdit).toBeCalledTimes(1) - expect(mockedRenameFile).toBeCalledWith( + expect(mockedWorkspaceEdit).toHaveBeenCalledTimes(1) + expect(mockedRenameFile).toHaveBeenCalledWith( path, Uri.joinPath(destination, filename) ) - expect(mockedApplyEdit).toBeCalledWith({ renameFile: mockedRenameFile }) + expect(mockedApplyEdit).toHaveBeenCalledWith({ + renameFile: mockedRenameFile + }) expect(moved).toBe(true) }) }) diff --git a/extension/src/path/selection/quickPick.test.ts b/extension/src/path/selection/quickPick.test.ts index 914ceca0f1..6c4bb3d707 100644 --- a/extension/src/path/selection/quickPick.test.ts +++ b/extension/src/path/selection/quickPick.test.ts @@ -22,16 +22,16 @@ describe('pickPaths', () => { mockedQuickPickManyValues.mockResolvedValueOnce([]) await pickPaths('plots', undefined) - expect(mockedShowError).toBeCalledTimes(1) - expect(mockedQuickPickManyValues).not.toBeCalled() + expect(mockedShowError).toHaveBeenCalledTimes(1) + expect(mockedQuickPickManyValues).not.toHaveBeenCalled() }) it('should not call quickPickManyValues if no plots paths are provided', async () => { mockedQuickPickManyValues.mockResolvedValueOnce([]) await pickPaths('plots', []) - expect(mockedShowError).toBeCalledTimes(1) - expect(mockedQuickPickManyValues).not.toBeCalled() + expect(mockedShowError).toHaveBeenCalledTimes(1) + expect(mockedQuickPickManyValues).not.toHaveBeenCalled() }) it('should call the quickPick with the correct items', async () => { @@ -66,9 +66,9 @@ describe('pickPaths', () => { await pickPaths('plots', plotPaths) - expect(mockedShowError).not.toBeCalled() - expect(mockedQuickPickManyValues).toBeCalledTimes(1) - expect(mockedQuickPickManyValues).toBeCalledWith( + expect(mockedShowError).not.toHaveBeenCalled() + expect(mockedQuickPickManyValues).toHaveBeenCalledTimes(1) + expect(mockedQuickPickManyValues).toHaveBeenCalledWith( [ { label: join('logs', 'loss.tsv'), diff --git a/extension/src/plots/model/index.test.ts b/extension/src/plots/model/index.test.ts index 92ef709618..3213a9511d 100644 --- a/extension/src/plots/model/index.test.ts +++ b/extension/src/plots/model/index.test.ts @@ -115,7 +115,7 @@ describe('plotsModel', () => { const newOrder = ['71f31cf', 'e93c7e6', 'ffbe811', 'workspace', 'main'] model.setComparisonOrder(newOrder) - expect(mementoUpdateSpy).toBeCalledTimes(1) + expect(mementoUpdateSpy).toHaveBeenCalledTimes(1) expect(mementoUpdateSpy).toHaveBeenCalledWith( PersistenceKey.PLOT_COMPARISON_ORDER + exampleDvcRoot, newOrder diff --git a/extension/src/python/index.test.ts b/extension/src/python/index.test.ts index 9ecdc136e3..0ee67648e3 100644 --- a/extension/src/python/index.test.ts +++ b/extension/src/python/index.test.ts @@ -25,20 +25,20 @@ describe('setupVenv', () => { await setupVenv(__dirname, envDir, 'dvc') - expect(createProcessSpy).toBeCalledTimes(3) - expect(createProcessSpy).toBeCalledWith({ + expect(createProcessSpy).toHaveBeenCalledTimes(3) + expect(createProcessSpy).toHaveBeenCalledWith({ args: ['-m', 'venv', envDir], cwd, executable: 'python3' }) - expect(createProcessSpy).toBeCalledWith({ + expect(createProcessSpy).toHaveBeenCalledWith({ args: ['-m', 'pip', 'install', '--upgrade', 'pip', 'wheel'], cwd, executable: join(cwd, envDir, 'bin', 'python') }) - expect(createProcessSpy).toBeCalledWith({ + expect(createProcessSpy).toHaveBeenCalledWith({ args: ['-m', 'pip', 'install', '--upgrade', 'dvc'], cwd, executable: join(cwd, envDir, 'bin', 'python') @@ -54,20 +54,20 @@ describe('setupVenv', () => { await setupVenv(__dirname, envDir, '-r', 'requirements.txt') - expect(createProcessSpy).toBeCalledTimes(3) - expect(createProcessSpy).toBeCalledWith({ + expect(createProcessSpy).toHaveBeenCalledTimes(3) + expect(createProcessSpy).toHaveBeenCalledWith({ args: ['-m', 'venv', envDir], cwd, executable: 'python' }) - expect(createProcessSpy).toBeCalledWith({ + expect(createProcessSpy).toHaveBeenCalledWith({ args: ['-m', 'pip', 'install', '--upgrade', 'pip', 'wheel'], cwd, executable: join(cwd, envDir, 'Scripts', 'python.exe') }) - expect(createProcessSpy).toBeCalledWith({ + expect(createProcessSpy).toHaveBeenCalledWith({ args: ['-m', 'pip', 'install', '--upgrade', '-r', 'requirements.txt'], cwd, executable: join(cwd, envDir, 'Scripts', 'python.exe') diff --git a/extension/src/repository/commands/index.test.ts b/extension/src/repository/commands/index.test.ts index 513af4bf37..d57fe14d50 100644 --- a/extension/src/repository/commands/index.test.ts +++ b/extension/src/repository/commands/index.test.ts @@ -57,8 +57,8 @@ describe('getResourceCommand', () => { }) expect(output).toStrictEqual(stdout) - expect(mockedFunc).toBeCalledWith(mockedDvcRoot, mockedRelPath) - expect(mockedFunc).toBeCalledTimes(1) + expect(mockedFunc).toHaveBeenCalledWith(mockedDvcRoot, mockedRelPath) + expect(mockedFunc).toHaveBeenCalledTimes(1) }) it('should return a function that throws if the first function fails without a force prompt', async () => { diff --git a/extension/src/repository/scmDecorationProvider.test.ts b/extension/src/repository/scmDecorationProvider.test.ts index 22cca69486..4b58212edd 100644 --- a/extension/src/repository/scmDecorationProvider.test.ts +++ b/extension/src/repository/scmDecorationProvider.test.ts @@ -54,7 +54,7 @@ describe('DecorationProvider', () => { committedAdded: new Set(addedPaths), tracked: new Set(addedPaths) } as ScmDecorationState) - expect(mockedDecorationsChangedFire).toBeCalledWith( + expect(mockedDecorationsChangedFire).toHaveBeenCalledWith( addedPaths.map(path => Uri.file(path)) ) }) @@ -83,7 +83,7 @@ describe('DecorationProvider', () => { tracked: new Set(subsetOfAddedPaths) } as ScmDecorationState) - expect(mockedDecorationsChangedFire).toBeCalledWith( + expect(mockedDecorationsChangedFire).toHaveBeenCalledWith( addedPaths.map(path => Uri.file(path)) ) }) @@ -162,7 +162,7 @@ describe('DecorationProvider', () => { scmDecorationProvider.setState(updatedState) - expect(mockedDecorationsChangedFire).toBeCalledWith( + expect(mockedDecorationsChangedFire).toHaveBeenCalledWith( [ ...committedAdded, ...committedDeleted, diff --git a/extension/src/setup.test.ts b/extension/src/setup.test.ts index 987b1351a1..af99bce943 100644 --- a/extension/src/setup.test.ts +++ b/extension/src/setup.test.ts @@ -90,8 +90,8 @@ describe('setupWorkspace', () => { await setupWorkspace() - expect(mockedQuickPickValue).toBeCalledTimes(1) - expect(mockedSetConfigValue).not.toBeCalled() + expect(mockedQuickPickValue).toHaveBeenCalledTimes(1) + expect(mockedSetConfigValue).not.toHaveBeenCalled() }) it('should return without setting any options if the dialog is cancelled at the DVC in virtual environment step', async () => { @@ -100,10 +100,13 @@ describe('setupWorkspace', () => { await setupWorkspace() - expect(mockedQuickPickValue).toBeCalledTimes(1) - expect(mockedQuickPickYesOrNo).toBeCalledTimes(1) - expect(mockedSetConfigValue).toBeCalledTimes(1) - expect(mockedSetConfigValue).toBeCalledWith('dvc.pythonPath', undefined) + expect(mockedQuickPickValue).toHaveBeenCalledTimes(1) + expect(mockedQuickPickYesOrNo).toHaveBeenCalledTimes(1) + expect(mockedSetConfigValue).toHaveBeenCalledTimes(1) + expect(mockedSetConfigValue).toHaveBeenCalledWith( + 'dvc.pythonPath', + undefined + ) }) it('should set the dvc path option to undefined if the CLI is installed in a virtual environment', async () => { @@ -112,9 +115,9 @@ describe('setupWorkspace', () => { await setupWorkspace() - expect(mockedQuickPickValue).toBeCalledTimes(1) - expect(mockedQuickPickYesOrNo).toBeCalledTimes(1) - expect(mockedSetConfigValue).toBeCalledWith('dvc.dvcPath', undefined) + expect(mockedQuickPickValue).toHaveBeenCalledTimes(1) + expect(mockedQuickPickYesOrNo).toHaveBeenCalledTimes(1) + expect(mockedSetConfigValue).toHaveBeenCalledWith('dvc.dvcPath', undefined) }) it('should return without setting any options if the dialog is cancelled at the virtual environment without DVC step', async () => { @@ -124,10 +127,13 @@ describe('setupWorkspace', () => { await setupWorkspace() - expect(mockedQuickPickValue).toBeCalledTimes(1) - expect(mockedQuickPickYesOrNo).toBeCalledTimes(2) - expect(mockedSetConfigValue).toBeCalledTimes(1) - expect(mockedSetConfigValue).toBeCalledWith('dvc.pythonPath', undefined) + expect(mockedQuickPickValue).toHaveBeenCalledTimes(1) + expect(mockedQuickPickYesOrNo).toHaveBeenCalledTimes(2) + expect(mockedSetConfigValue).toHaveBeenCalledTimes(1) + expect(mockedSetConfigValue).toHaveBeenCalledWith( + 'dvc.pythonPath', + undefined + ) }) it("should set the dvc path option to dvc if there is a virtual environment which doesn't include the CLI but it is available globally", async () => { @@ -137,11 +143,14 @@ describe('setupWorkspace', () => { await setupWorkspace() - expect(mockedQuickPickValue).toBeCalledTimes(1) - expect(mockedQuickPickYesOrNo).toBeCalledTimes(2) - expect(mockedSetConfigValue).toBeCalledTimes(2) - expect(mockedSetConfigValue).toBeCalledWith('dvc.pythonPath', undefined) - expect(mockedSetConfigValue).toBeCalledWith('dvc.dvcPath', 'dvc') + expect(mockedQuickPickValue).toHaveBeenCalledTimes(1) + expect(mockedQuickPickYesOrNo).toHaveBeenCalledTimes(2) + expect(mockedSetConfigValue).toHaveBeenCalledTimes(2) + expect(mockedSetConfigValue).toHaveBeenCalledWith( + 'dvc.pythonPath', + undefined + ) + expect(mockedSetConfigValue).toHaveBeenCalledWith('dvc.dvcPath', 'dvc') }) it("should set the dvc path option to the entered value if there is a virtual environment that doesn't include a CLI and there is no global option", async () => { @@ -153,13 +162,19 @@ describe('setupWorkspace', () => { await setupWorkspace() - expect(mockedQuickPickValue).toBeCalledTimes(1) - expect(mockedQuickPickYesOrNo).toBeCalledTimes(2) - expect(mockedQuickPickOneOrInput).toBeCalledTimes(1) - expect(mockedPickFile).not.toBeCalled() - expect(mockedSetConfigValue).toBeCalledTimes(2) - expect(mockedSetConfigValue).toBeCalledWith('dvc.pythonPath', undefined) - expect(mockedSetConfigValue).toBeCalledWith('dvc.dvcPath', mockedDvcPath) + expect(mockedQuickPickValue).toHaveBeenCalledTimes(1) + expect(mockedQuickPickYesOrNo).toHaveBeenCalledTimes(2) + expect(mockedQuickPickOneOrInput).toHaveBeenCalledTimes(1) + expect(mockedPickFile).not.toHaveBeenCalled() + expect(mockedSetConfigValue).toHaveBeenCalledTimes(2) + expect(mockedSetConfigValue).toHaveBeenCalledWith( + 'dvc.pythonPath', + undefined + ) + expect(mockedSetConfigValue).toHaveBeenCalledWith( + 'dvc.dvcPath', + mockedDvcPath + ) }) it("should set the dvc path option to the picked file's path if there is a virtual environment that doesn't include a CLI and there is no global option", async () => { @@ -172,13 +187,19 @@ describe('setupWorkspace', () => { await setupWorkspace() - expect(mockedQuickPickValue).toBeCalledTimes(1) - expect(mockedQuickPickYesOrNo).toBeCalledTimes(2) - expect(mockedQuickPickOneOrInput).toBeCalledTimes(1) - expect(mockedPickFile).toBeCalledTimes(1) - expect(mockedSetConfigValue).toBeCalledTimes(2) - expect(mockedSetConfigValue).toBeCalledWith('dvc.pythonPath', undefined) - expect(mockedSetConfigValue).toBeCalledWith('dvc.dvcPath', mockedDvcPath) + expect(mockedQuickPickValue).toHaveBeenCalledTimes(1) + expect(mockedQuickPickYesOrNo).toHaveBeenCalledTimes(2) + expect(mockedQuickPickOneOrInput).toHaveBeenCalledTimes(1) + expect(mockedPickFile).toHaveBeenCalledTimes(1) + expect(mockedSetConfigValue).toHaveBeenCalledTimes(2) + expect(mockedSetConfigValue).toHaveBeenCalledWith( + 'dvc.pythonPath', + undefined + ) + expect(mockedSetConfigValue).toHaveBeenCalledWith( + 'dvc.dvcPath', + mockedDvcPath + ) }) it('should not set the python or dvc path options if the user cancels the dialog at the pick a python interpreter step', async () => { @@ -187,10 +208,10 @@ describe('setupWorkspace', () => { await setupWorkspace() - expect(mockedQuickPickValue).toBeCalledTimes(1) - expect(mockedQuickPickYesOrNo).not.toBeCalled() - expect(mockedQuickPickOneOrInput).toBeCalledTimes(1) - expect(mockedSetConfigValue).not.toBeCalled() + expect(mockedQuickPickValue).toHaveBeenCalledTimes(1) + expect(mockedQuickPickYesOrNo).not.toHaveBeenCalled() + expect(mockedQuickPickOneOrInput).toHaveBeenCalledTimes(1) + expect(mockedSetConfigValue).not.toHaveBeenCalled() }) it("should set the python and dvc path options to the picked file's path if there is a virtual environment that doesn't include a CLI and there is no global option", async () => { @@ -206,16 +227,19 @@ describe('setupWorkspace', () => { await setupWorkspace() - expect(mockedQuickPickValue).toBeCalledTimes(1) - expect(mockedQuickPickYesOrNo).toBeCalledTimes(2) - expect(mockedQuickPickOneOrInput).toBeCalledTimes(2) - expect(mockedPickFile).toBeCalledTimes(2) - expect(mockedSetConfigValue).toBeCalledTimes(2) - expect(mockedSetConfigValue).toBeCalledWith( + expect(mockedQuickPickValue).toHaveBeenCalledTimes(1) + expect(mockedQuickPickYesOrNo).toHaveBeenCalledTimes(2) + expect(mockedQuickPickOneOrInput).toHaveBeenCalledTimes(2) + expect(mockedPickFile).toHaveBeenCalledTimes(2) + expect(mockedSetConfigValue).toHaveBeenCalledTimes(2) + expect(mockedSetConfigValue).toHaveBeenCalledWith( 'dvc.pythonPath', mockedPythonPath ) - expect(mockedSetConfigValue).toBeCalledWith('dvc.dvcPath', mockedDvcPath) + expect(mockedSetConfigValue).toHaveBeenCalledWith( + 'dvc.dvcPath', + mockedDvcPath + ) }) }) @@ -235,8 +259,8 @@ describe('setup', () => { await setup(extension) - expect(mockedCanRunCli).not.toBeCalled() - expect(mockedInitialize).not.toBeCalled() + expect(mockedCanRunCli).not.toHaveBeenCalled() + expect(mockedInitialize).not.toHaveBeenCalled() }) it('should set the DVC roots even if the cli cannot be used', async () => { @@ -245,7 +269,7 @@ describe('setup', () => { await setup(extension) - expect(mockedSetRoots).toBeCalledTimes(1) + expect(mockedSetRoots).toHaveBeenCalledTimes(1) }) it('should not alert the user if the workspace has no DVC project and the cli cannot be found', async () => { @@ -254,13 +278,13 @@ describe('setup', () => { mockedCanRunCli.mockRejectedValueOnce(new Error('command not found: dvc')) await setup(extension) - expect(mockedSetRoots).toBeCalledTimes(1) - expect(mockedGetConfigValue).not.toBeCalled() - expect(mockedWarnWithOptions).not.toBeCalled() - expect(mockedSetupWorkspace).not.toBeCalled() - expect(mockedSetUserConfigValue).not.toBeCalled() - expect(mockedResetMembers).toBeCalledTimes(1) - expect(mockedInitialize).not.toBeCalled() + expect(mockedSetRoots).toHaveBeenCalledTimes(1) + expect(mockedGetConfigValue).not.toHaveBeenCalled() + expect(mockedWarnWithOptions).not.toHaveBeenCalled() + expect(mockedSetupWorkspace).not.toHaveBeenCalled() + expect(mockedSetUserConfigValue).not.toHaveBeenCalled() + expect(mockedResetMembers).toHaveBeenCalledTimes(1) + expect(mockedInitialize).not.toHaveBeenCalled() }) it('should not alert the user if the workspace contains a DVC project, the cli cannot be found and the do not show option is set', async () => { @@ -270,13 +294,13 @@ describe('setup', () => { mockedGetConfigValue.mockReturnValueOnce(true) await setup(extension) - expect(mockedSetRoots).toBeCalledTimes(1) - expect(mockedGetConfigValue).toBeCalledTimes(1) - expect(mockedWarnWithOptions).not.toBeCalled() - expect(mockedSetupWorkspace).not.toBeCalled() - expect(mockedSetUserConfigValue).not.toBeCalled() - expect(mockedResetMembers).toBeCalledTimes(1) - expect(mockedInitialize).not.toBeCalled() + expect(mockedSetRoots).toHaveBeenCalledTimes(1) + expect(mockedGetConfigValue).toHaveBeenCalledTimes(1) + expect(mockedWarnWithOptions).not.toHaveBeenCalled() + expect(mockedSetupWorkspace).not.toHaveBeenCalled() + expect(mockedSetUserConfigValue).not.toHaveBeenCalled() + expect(mockedResetMembers).toHaveBeenCalledTimes(1) + expect(mockedInitialize).not.toHaveBeenCalled() }) it('should alert the user if the workspace contains a DVC project and the cli cannot be found', async () => { @@ -292,11 +316,11 @@ describe('setup', () => { await setup(extension) await flushPromises() - expect(mockedSetRoots).toBeCalledTimes(1) - expect(mockedGetConfigValue).toBeCalledTimes(1) - expect(mockedWarnWithOptions).toBeCalledTimes(1) - expect(mockedResetMembers).toBeCalledTimes(1) - expect(mockedInitialize).not.toBeCalled() + expect(mockedSetRoots).toHaveBeenCalledTimes(1) + expect(mockedGetConfigValue).toHaveBeenCalledTimes(1) + expect(mockedWarnWithOptions).toHaveBeenCalledTimes(1) + expect(mockedResetMembers).toHaveBeenCalledTimes(1) + expect(mockedInitialize).not.toHaveBeenCalled() }) it('should try to setup the workspace if the workspace contains a DVC project, the cli cannot be found and the user selects setup the workspace', async () => { @@ -312,14 +336,14 @@ describe('setup', () => { await setup(extension) await flushPromises() - expect(mockedSetRoots).toBeCalledTimes(1) - expect(mockedGetConfigValue).toBeCalledTimes(1) - expect(mockedWarnWithOptions).toBeCalledTimes(1) - expect(mockedSetupWorkspace).toBeCalledTimes(1) - expect(mockedExecuteCommand).not.toBeCalled() - expect(mockedSetUserConfigValue).not.toBeCalled() - expect(mockedResetMembers).toBeCalledTimes(1) - expect(mockedInitialize).not.toBeCalled() + expect(mockedSetRoots).toHaveBeenCalledTimes(1) + expect(mockedGetConfigValue).toHaveBeenCalledTimes(1) + expect(mockedWarnWithOptions).toHaveBeenCalledTimes(1) + expect(mockedSetupWorkspace).toHaveBeenCalledTimes(1) + expect(mockedExecuteCommand).not.toHaveBeenCalled() + expect(mockedSetUserConfigValue).not.toHaveBeenCalled() + expect(mockedResetMembers).toHaveBeenCalledTimes(1) + expect(mockedInitialize).not.toHaveBeenCalled() }) it('should try to select the python interpreter if the workspace contains a DVC project, the cli cannot be found and the user decides to select the python interpreter', async () => { @@ -335,14 +359,14 @@ describe('setup', () => { await setup(extension) await flushPromises() - expect(mockedSetRoots).toBeCalledTimes(1) - expect(mockedGetConfigValue).toBeCalledTimes(1) - expect(mockedWarnWithOptions).toBeCalledTimes(1) - expect(mockedSetupWorkspace).toBeCalledTimes(0) - expect(mockedExecuteCommand).toBeCalledTimes(1) - expect(mockedSetUserConfigValue).not.toBeCalled() - expect(mockedResetMembers).toBeCalledTimes(1) - expect(mockedInitialize).not.toBeCalled() + expect(mockedSetRoots).toHaveBeenCalledTimes(1) + expect(mockedGetConfigValue).toHaveBeenCalledTimes(1) + expect(mockedWarnWithOptions).toHaveBeenCalledTimes(1) + expect(mockedSetupWorkspace).toHaveBeenCalledTimes(0) + expect(mockedExecuteCommand).toHaveBeenCalledTimes(1) + expect(mockedSetUserConfigValue).not.toHaveBeenCalled() + expect(mockedResetMembers).toHaveBeenCalledTimes(1) + expect(mockedInitialize).not.toHaveBeenCalled() }) it('should set a user config option if the workspace contains a DVC project, the cli cannot be found and the user selects never', async () => { @@ -358,14 +382,14 @@ describe('setup', () => { await setup(extension) await flushPromises() - expect(mockedSetRoots).toBeCalledTimes(1) - expect(mockedGetConfigValue).toBeCalledTimes(1) - expect(mockedWarnWithOptions).toBeCalledTimes(1) - expect(mockedSetupWorkspace).not.toBeCalled() - expect(mockedExecuteCommand).not.toBeCalled() - expect(mockedSetUserConfigValue).toBeCalledTimes(1) - expect(mockedResetMembers).toBeCalledTimes(1) - expect(mockedInitialize).not.toBeCalled() + expect(mockedSetRoots).toHaveBeenCalledTimes(1) + expect(mockedGetConfigValue).toHaveBeenCalledTimes(1) + expect(mockedWarnWithOptions).toHaveBeenCalledTimes(1) + expect(mockedSetupWorkspace).not.toHaveBeenCalled() + expect(mockedExecuteCommand).not.toHaveBeenCalled() + expect(mockedSetUserConfigValue).toHaveBeenCalledTimes(1) + expect(mockedResetMembers).toHaveBeenCalledTimes(1) + expect(mockedInitialize).not.toHaveBeenCalled() }) it('should not send telemetry or set the cli as unavailable or run initialization if roots have not been found but the cli can be run', async () => { @@ -374,10 +398,10 @@ describe('setup', () => { mockedCanRunCli.mockResolvedValueOnce(true) await setup(extension) - expect(mockedSetRoots).toBeCalledTimes(1) - expect(mockedResetMembers).toBeCalledTimes(1) - expect(mockedSetAvailable).not.toBeCalled() - expect(mockedInitialize).not.toBeCalled() + expect(mockedSetRoots).toHaveBeenCalledTimes(1) + expect(mockedResetMembers).toHaveBeenCalledTimes(1) + expect(mockedSetAvailable).not.toHaveBeenCalled() + expect(mockedInitialize).not.toHaveBeenCalled() }) it('should run initialization if roots have been found and the cli can be run', async () => { @@ -386,8 +410,8 @@ describe('setup', () => { mockedCanRunCli.mockResolvedValueOnce(true) await setup(extension) - expect(mockedResetMembers).not.toBeCalled() - expect(mockedInitialize).toBeCalledTimes(1) + expect(mockedResetMembers).not.toHaveBeenCalled() + expect(mockedInitialize).toHaveBeenCalledTimes(1) }) it('should run reset if the cli cannot be run and there is a workspace folder open', async () => { @@ -396,7 +420,7 @@ describe('setup', () => { mockedCanRunCli.mockResolvedValueOnce(false) await setup(extension) - expect(mockedResetMembers).toBeCalledTimes(1) - expect(mockedInitialize).not.toBeCalled() + expect(mockedResetMembers).toHaveBeenCalledTimes(1) + expect(mockedInitialize).not.toHaveBeenCalled() }) }) diff --git a/extension/src/telemetry/index.test.ts b/extension/src/telemetry/index.test.ts index 5ab961ff7f..cafc9d7d4e 100644 --- a/extension/src/telemetry/index.test.ts +++ b/extension/src/telemetry/index.test.ts @@ -52,10 +52,10 @@ describe('getTelemetryReporter', () => { telemetryReporter = getTelemetryReporter() expect(telemetryReporter).toBeDefined() - expect(mockedGetExtension).toBeCalledTimes(1) - expect(mockedGetExtension).toBeCalledWith('iterative.dvc') - expect(mockedTelemetryReporter).toBeCalledTimes(1) - expect(mockedTelemetryReporter).toBeCalledWith( + expect(mockedGetExtension).toHaveBeenCalledTimes(1) + expect(mockedGetExtension).toHaveBeenCalledWith('iterative.dvc') + expect(mockedTelemetryReporter).toHaveBeenCalledTimes(1) + expect(mockedTelemetryReporter).toHaveBeenCalledWith( EXTENSION_ID, mockedPackageJSON.version, APPLICATION_INSIGHTS_KEY, @@ -67,8 +67,8 @@ describe('getTelemetryReporter', () => { const sameTelemetryReporter = getTelemetryReporter() expect(telemetryReporter).toStrictEqual(sameTelemetryReporter) - expect(mockedTelemetryReporter).not.toBeCalled() - expect(mockedGetExtension).not.toBeCalled() + expect(mockedTelemetryReporter).not.toHaveBeenCalled() + expect(mockedGetExtension).not.toHaveBeenCalled() }) }) @@ -95,7 +95,7 @@ describe('sendTelemetryEvent', () => { mockedMeasurements ) - expect(mockedSendTelemetryEvent).toBeCalledWith( + expect(mockedSendTelemetryEvent).toHaveBeenCalledWith( mockedEventName, { a: '1', diff --git a/extension/src/telemetry/uuid.test.ts b/extension/src/telemetry/uuid.test.ts index 1b77189860..b345edf46c 100644 --- a/extension/src/telemetry/uuid.test.ts +++ b/extension/src/telemetry/uuid.test.ts @@ -21,9 +21,9 @@ describe('readOrCreateUserId', () => { mockedExists.mockReturnValueOnce(false).mockReturnValueOnce(false) readOrCreateUserId() - expect(mockedReadJson).not.toBeCalled() - expect(mockedWriteJson).toBeCalledTimes(2) - expect(mockedWriteJson).toBeCalledWith( + expect(mockedReadJson).not.toHaveBeenCalled() + expect(mockedWriteJson).toHaveBeenCalledTimes(2) + expect(mockedWriteJson).toHaveBeenCalledWith( expect.stringContaining(sep + 'telemetry'), expect.objectContaining({ user_id: expect.stringContaining('-') }) ) @@ -34,12 +34,12 @@ describe('readOrCreateUserId', () => { mockedReadJson.mockReturnValueOnce(mockedConfig) readOrCreateUserId() - expect(mockedWriteJson).toBeCalledTimes(1) - expect(mockedWriteJson).toBeCalledWith( + expect(mockedWriteJson).toHaveBeenCalledTimes(1) + expect(mockedWriteJson).toHaveBeenCalledWith( expect.stringContaining(sep + 'telemetry'), mockedConfig ) - expect(mockedWriteJson).not.toBeCalledWith( + expect(mockedWriteJson).not.toHaveBeenCalledWith( expect.stringContaining('dvc'), mockedConfig ) @@ -50,15 +50,15 @@ describe('readOrCreateUserId', () => { mockedReadJson.mockReturnValueOnce(mockedConfig) readOrCreateUserId() - expect(mockedReadJson).toBeCalledTimes(1) - expect(mockedWriteJson).toBeCalledTimes(1) + expect(mockedReadJson).toHaveBeenCalledTimes(1) + expect(mockedWriteJson).toHaveBeenCalledTimes(1) - expect(mockedWriteJson).not.toBeCalledWith( + expect(mockedWriteJson).not.toHaveBeenCalledWith( expect.stringContaining(sep + 'telemetry'), mockedConfig ) - expect(mockedWriteJson).toBeCalledWith( + expect(mockedWriteJson).toHaveBeenCalledWith( expect.stringContaining('dvc'), expect.objectContaining({ user_id: expect.stringContaining('-') }) ) @@ -71,10 +71,10 @@ describe('readOrCreateUserId', () => { .mockReturnValueOnce({ 'some-other-info': true, user_id: 'bogus-id' }) readOrCreateUserId() - expect(mockedReadJson).toBeCalledTimes(2) - expect(mockedWriteJson).toBeCalledTimes(1) + expect(mockedReadJson).toHaveBeenCalledTimes(2) + expect(mockedWriteJson).toHaveBeenCalledTimes(1) - expect(mockedWriteJson).toBeCalledWith( + expect(mockedWriteJson).toHaveBeenCalledWith( expect.stringContaining(sep + 'telemetry'), { 'do-not-track': true, @@ -93,8 +93,8 @@ describe('getUserId', () => { const user_id = getUserId() expect(user_id).toStrictEqual(mockedUserId) - expect(mockedExists).toBeCalledTimes(2) - expect(mockedReadJson).toBeCalledTimes(1) + expect(mockedExists).toHaveBeenCalledTimes(2) + expect(mockedReadJson).toHaveBeenCalledTimes(1) mockedExists.mockClear() mockedReadJson.mockClear() @@ -103,7 +103,7 @@ describe('getUserId', () => { getUserId() getUserId() - expect(mockedExists).not.toBeCalled() - expect(mockedReadJson).not.toBeCalled() + expect(mockedExists).not.toHaveBeenCalled() + expect(mockedReadJson).not.toHaveBeenCalled() }) }) diff --git a/extension/src/util/disposable.test.ts b/extension/src/util/disposable.test.ts index 47760cda6f..3ee8cc7941 100644 --- a/extension/src/util/disposable.test.ts +++ b/extension/src/util/disposable.test.ts @@ -39,7 +39,7 @@ describe('reset', () => { reset(disposables, disposer) - expect(mockedDispose).toBeCalledTimes(3) + expect(mockedDispose).toHaveBeenCalledTimes(3) }) it('should stop the disposer tracking the disposables', () => { @@ -50,6 +50,6 @@ describe('reset', () => { reset(disposables, disposer) - expect(mockedUntrack).toBeCalledWith(disposable) + expect(mockedUntrack).toHaveBeenCalledWith(disposable) }) }) diff --git a/extension/src/vscode/context.test.ts b/extension/src/vscode/context.test.ts index 21f555e8b5..0c6b01eca2 100644 --- a/extension/src/vscode/context.test.ts +++ b/extension/src/vscode/context.test.ts @@ -16,6 +16,6 @@ describe('setContextValue', () => { const key = 'my important key' const value = 'value that if not set everything breaks' setContextValue(key, value) - expect(mockedExecuteCommand).toBeCalledWith('setContext', key, value) + expect(mockedExecuteCommand).toHaveBeenCalledWith('setContext', key, value) }) }) diff --git a/extension/src/vscode/inputBox.test.ts b/extension/src/vscode/inputBox.test.ts index db339db466..d8958a9f53 100644 --- a/extension/src/vscode/inputBox.test.ts +++ b/extension/src/vscode/inputBox.test.ts @@ -15,7 +15,7 @@ describe('getInput', () => { it('should call window.showInputBox with the provided title', async () => { const aggressiveText = 'TELL ME WHAT YOU WANT' as Title await getInput(aggressiveText) - expect(mockedInputBox).toBeCalledTimes(1) - expect(mockedInputBox).toBeCalledWith({ title: aggressiveText }) + expect(mockedInputBox).toHaveBeenCalledTimes(1) + expect(mockedInputBox).toHaveBeenCalledWith({ title: aggressiveText }) }) }) diff --git a/extension/src/vscode/modal.test.ts b/extension/src/vscode/modal.test.ts index dbac667212..54cf931d56 100644 --- a/extension/src/vscode/modal.test.ts +++ b/extension/src/vscode/modal.test.ts @@ -24,7 +24,7 @@ describe('warnOfConsequences', () => { const response = await warnOfConsequences('WHAT DO I DO?', ...options) expect(response).toStrictEqual(userSelection) - expect(mockedShowWarningMessage).toBeCalledTimes(1) + expect(mockedShowWarningMessage).toHaveBeenCalledTimes(1) }) it('should return undefined if the modal is cancelled', async () => { @@ -36,6 +36,6 @@ describe('warnOfConsequences', () => { const response = await warnOfConsequences('WHAT DO I DO?', ...options) expect(response).toStrictEqual(modalCancelled) - expect(mockedShowWarningMessage).toBeCalledTimes(1) + expect(mockedShowWarningMessage).toHaveBeenCalledTimes(1) }) }) diff --git a/extension/src/vscode/quickPick.test.ts b/extension/src/vscode/quickPick.test.ts index 9f6b684c84..e30c13a1ab 100644 --- a/extension/src/vscode/quickPick.test.ts +++ b/extension/src/vscode/quickPick.test.ts @@ -55,7 +55,7 @@ describe('quickPickValue', () => { } ] const probablyC = await quickPickValue(items, { placeHolder, title }) - expect(mockedShowQuickPick).toBeCalledWith(items, { + expect(mockedShowQuickPick).toHaveBeenCalledWith(items, { canPickMany: false, placeHolder, title @@ -93,7 +93,7 @@ describe('quickPickManyValues', () => { } ] const result = await quickPickManyValues(items, { placeHolder, title }) - expect(mockedShowQuickPick).toBeCalledWith(items, { + expect(mockedShowQuickPick).toHaveBeenCalledWith(items, { canPickMany: true, placeHolder, title @@ -109,7 +109,7 @@ describe('quickPickOne', () => { const noResponse = await quickPickOne(['a', 'b', 'c'], placeHolder) - expect(mockedShowQuickPick).toBeCalledWith(['a', 'b', 'c'], { + expect(mockedShowQuickPick).toHaveBeenCalledWith(['a', 'b', 'c'], { canPickMany: false, placeHolder }) @@ -135,7 +135,7 @@ describe('quickPickYesOrNo', () => { title }) - expect(mockedShowQuickPick).toBeCalledWith( + expect(mockedShowQuickPick).toHaveBeenCalledWith( [ yesItem, { description: noDescription, label: Response.NO, value: false } diff --git a/extension/src/vscode/recommend.test.ts b/extension/src/vscode/recommend.test.ts index a042052f49..d94868797c 100644 --- a/extension/src/vscode/recommend.test.ts +++ b/extension/src/vscode/recommend.test.ts @@ -24,8 +24,8 @@ describe('recommendRedHatExtension', () => { mockedShowInformationMessage.mockResolvedValueOnce(Response.NEVER) await recommendRedHatExtension() - expect(mockedSetUserConfigValue).toBeCalledTimes(1) - expect(mockedSetUserConfigValue).toBeCalledWith( + expect(mockedSetUserConfigValue).toHaveBeenCalledTimes(1) + expect(mockedSetUserConfigValue).toHaveBeenCalledWith( ConfigKey.DO_NOT_RECOMMEND_RED_HAT, true ) @@ -37,8 +37,8 @@ describe('recommendRedHatExtension', () => { await recommendRedHatExtension() - expect(mockedExecuteCommand).toBeCalledTimes(1) - expect(mockedExecuteCommand).toBeCalledWith( + expect(mockedExecuteCommand).toHaveBeenCalledTimes(1) + expect(mockedExecuteCommand).toHaveBeenCalledWith( 'workbench.extensions.search', '@id:redhat.vscode-yaml' ) @@ -48,13 +48,13 @@ describe('recommendRedHatExtension', () => { mockedShowInformationMessage.mockResolvedValueOnce(Response.NO) await recommendRedHatExtension() - expect(mockedSetUserConfigValue).not.toBeCalled() + expect(mockedSetUserConfigValue).not.toHaveBeenCalled() }) it('should not set any options if the user cancels the dialog', async () => { mockedShowInformationMessage.mockResolvedValueOnce(undefined) await recommendRedHatExtension() - expect(mockedSetUserConfigValue).not.toBeCalled() + expect(mockedSetUserConfigValue).not.toHaveBeenCalled() }) }) diff --git a/extension/src/vscode/resourcePicker.test.ts b/extension/src/vscode/resourcePicker.test.ts index aeb85e4ba3..ceea1eeab5 100644 --- a/extension/src/vscode/resourcePicker.test.ts +++ b/extension/src/vscode/resourcePicker.test.ts @@ -20,7 +20,7 @@ describe('pickFile', () => { await pickFile(mockedTitle) - expect(mockedShowOpenDialog).toBeCalledWith({ + expect(mockedShowOpenDialog).toHaveBeenCalledWith({ canSelectFolders: false, canSelectMany: false, title: mockedTitle @@ -46,7 +46,7 @@ describe('pickResources', () => { await pickResources(mockedTitle) - expect(mockedShowOpenDialog).toBeCalledWith({ + expect(mockedShowOpenDialog).toHaveBeenCalledWith({ canSelectFiles: true, canSelectFolders: true, canSelectMany: true, diff --git a/extension/src/vscode/toast.test.ts b/extension/src/vscode/toast.test.ts index caf0642d1c..8b495c6b5d 100644 --- a/extension/src/vscode/toast.test.ts +++ b/extension/src/vscode/toast.test.ts @@ -27,8 +27,12 @@ describe('Toast', () => { await Toast.errorWithOptions(message, option1, option2) - expect(mockedShowErrorMessage).toBeCalledTimes(1) - expect(mockedShowErrorMessage).toBeCalledWith(message, option1, option2) + expect(mockedShowErrorMessage).toHaveBeenCalledTimes(1) + expect(mockedShowErrorMessage).toHaveBeenCalledWith( + message, + option1, + option2 + ) }) }) @@ -40,10 +44,13 @@ describe('Toast', () => { await Toast.showOutput(mockedExperimentApply(defaultPath, exampleExpName)) - expect(mockedExperimentApply).toBeCalledWith(defaultPath, exampleExpName) + expect(mockedExperimentApply).toHaveBeenCalledWith( + defaultPath, + exampleExpName + ) - expect(mockedShowInformationMessage).toBeCalledTimes(1) - expect(mockedShowInformationMessage).toBeCalledWith(mockedStdOut) + expect(mockedShowInformationMessage).toHaveBeenCalledTimes(1) + expect(mockedShowInformationMessage).toHaveBeenCalledWith(mockedStdOut) }) it('reports operation successful when no output is returned for the given command', async () => { @@ -53,10 +60,13 @@ describe('Toast', () => { await Toast.showOutput(mockedExperimentApply(defaultPath, exampleExpName)) - expect(mockedExperimentApply).toBeCalledWith(defaultPath, exampleExpName) + expect(mockedExperimentApply).toHaveBeenCalledWith( + defaultPath, + exampleExpName + ) - expect(mockedShowInformationMessage).toBeCalledTimes(1) - expect(mockedShowInformationMessage).toBeCalledWith( + expect(mockedShowInformationMessage).toHaveBeenCalledTimes(1) + expect(mockedShowInformationMessage).toHaveBeenCalledWith( 'Operation successful.' ) }) diff --git a/extension/src/vscode/walkthrough.test.ts b/extension/src/vscode/walkthrough.test.ts index 3428bf9d3c..03019e9635 100644 --- a/extension/src/vscode/walkthrough.test.ts +++ b/extension/src/vscode/walkthrough.test.ts @@ -27,20 +27,20 @@ beforeEach(() => { describe('showWalkthroughOnFirstUse', () => { it('should ask to show the walkthrough after a new install', async () => { await showWalkthroughOnFirstUse(true) - expect(mockedAskShowOrCloseOrNever).toBeCalledTimes(1) + expect(mockedAskShowOrCloseOrNever).toHaveBeenCalledTimes(1) }) it('should not ask to show the walkthrough when the install is not new', async () => { await showWalkthroughOnFirstUse(false) - expect(mockedAskShowOrCloseOrNever).not.toBeCalled() + expect(mockedAskShowOrCloseOrNever).not.toHaveBeenCalled() }) it('should not ask to show the walkthrough when the user has set a config option', async () => { mockedGetConfigValue.mockReturnValueOnce(true) await showWalkthroughOnFirstUse(true) - expect(mockedAskShowOrCloseOrNever).not.toBeCalled() - expect(mockedGetConfigValue).toBeCalledTimes(1) - expect(mockedGetConfigValue).toBeCalledWith( + expect(mockedAskShowOrCloseOrNever).not.toHaveBeenCalled() + expect(mockedGetConfigValue).toHaveBeenCalledTimes(1) + expect(mockedGetConfigValue).toHaveBeenCalledWith( ConfigKey.DO_NOT_SHOW_WALKTHROUGH_AFTER_INSTALL ) }) @@ -49,8 +49,8 @@ describe('showWalkthroughOnFirstUse', () => { mockedAskShowOrCloseOrNever.mockResolvedValueOnce(Response.NEVER) await showWalkthroughOnFirstUse(true) - expect(mockedSetConfigValue).toBeCalledTimes(1) - expect(mockedSetConfigValue).toBeCalledWith( + expect(mockedSetConfigValue).toHaveBeenCalledTimes(1) + expect(mockedSetConfigValue).toHaveBeenCalledWith( ConfigKey.DO_NOT_SHOW_WALKTHROUGH_AFTER_INSTALL, true ) @@ -60,8 +60,8 @@ describe('showWalkthroughOnFirstUse', () => { mockedAskShowOrCloseOrNever.mockResolvedValueOnce(Response.SHOW) await showWalkthroughOnFirstUse(true) - expect(mockedSetConfigValue).not.toBeCalled() - expect(mockedExecuteCommand).toBeCalledWith( + expect(mockedSetConfigValue).not.toHaveBeenCalled() + expect(mockedExecuteCommand).toHaveBeenCalledWith( RegisteredCommands.EXTENSION_GET_STARTED ) }) @@ -70,15 +70,15 @@ describe('showWalkthroughOnFirstUse', () => { mockedAskShowOrCloseOrNever.mockResolvedValueOnce(undefined) await showWalkthroughOnFirstUse(true) - expect(mockedSetConfigValue).not.toBeCalled() - expect(mockedExecuteCommand).not.toBeCalled() + expect(mockedSetConfigValue).not.toHaveBeenCalled() + expect(mockedExecuteCommand).not.toHaveBeenCalled() }) it('should take no action if the user respond with close', async () => { mockedAskShowOrCloseOrNever.mockResolvedValueOnce(Response.CLOSE) await showWalkthroughOnFirstUse(true) - expect(mockedSetConfigValue).not.toBeCalled() - expect(mockedExecuteCommand).not.toBeCalled() + expect(mockedSetConfigValue).not.toHaveBeenCalled() + expect(mockedExecuteCommand).not.toHaveBeenCalled() }) }) diff --git a/webview/src/experiments/components/App.test.tsx b/webview/src/experiments/components/App.test.tsx index 7c1f9f9093..ec4bbacec9 100644 --- a/webview/src/experiments/components/App.test.tsx +++ b/webview/src/experiments/components/App.test.tsx @@ -258,7 +258,7 @@ describe('App', () => { mockPostMessage.mockClear() fireEvent.click(expandButton) - expect(mockPostMessage).not.toBeCalled() + expect(mockPostMessage).not.toHaveBeenCalled() fireEvent.keyDown(expandButton, { bubbles: true, @@ -266,7 +266,7 @@ describe('App', () => { key: 'Enter', keyCode: 13 }) - expect(mockPostMessage).not.toBeCalled() + expect(mockPostMessage).not.toHaveBeenCalled() }) }) @@ -356,8 +356,8 @@ describe('App', () => { fireEvent.click(screen.getByText(label)) - expect(mockPostMessage).toBeCalledTimes(1) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledTimes(1) + expect(mockPostMessage).toHaveBeenCalledWith({ payload: id, type: MessageFromWebviewType.TOGGLE_EXPERIMENT }) @@ -385,7 +385,7 @@ describe('App', () => { key: 'Enter', keyCode: 13 }) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ payload: 'main', type: MessageFromWebviewType.TOGGLE_EXPERIMENT }) @@ -398,7 +398,7 @@ describe('App', () => { key: ' ', keyCode: 32 }) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ payload: 'main', type: MessageFromWebviewType.TOGGLE_EXPERIMENT }) @@ -409,7 +409,7 @@ describe('App', () => { code: 'keyA', key: 'a' }) - expect(mockPostMessage).not.toBeCalled() + expect(mockPostMessage).not.toHaveBeenCalled() }) }) @@ -823,7 +823,7 @@ describe('App', () => { const starIcon = within(workspaceRow).getByTestId('star-icon') fireEvent.click(starIcon) - expect(mockPostMessage).not.toBeCalled() + expect(mockPostMessage).not.toHaveBeenCalled() }) it('should toggle the star status of an experiment by clicking the star icon', () => { @@ -834,8 +834,8 @@ describe('App', () => { const starIcon = within(mainRow).getByTestId('star-icon') fireEvent.click(starIcon) - expect(mockPostMessage).toBeCalledTimes(1) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledTimes(1) + expect(mockPostMessage).toHaveBeenCalledWith({ payload: ['main'], type: MessageFromWebviewType.TOGGLE_EXPERIMENT_STAR }) @@ -853,8 +853,8 @@ describe('App', () => { const starOption = screen.getByText('Star') fireEvent.click(starOption) - expect(mockPostMessage).toBeCalledTimes(1) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledTimes(1) + expect(mockPostMessage).toHaveBeenCalledWith({ payload: ['main'], type: MessageFromWebviewType.TOGGLE_EXPERIMENT_STAR }) @@ -875,8 +875,8 @@ describe('App', () => { const starOption = screen.getByText('Star') fireEvent.click(starOption) - expect(mockPostMessage).toBeCalledTimes(1) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledTimes(1) + expect(mockPostMessage).toHaveBeenCalledWith({ payload: ['main', 'exp-e7a67'], type: MessageFromWebviewType.TOGGLE_EXPERIMENT_STAR }) @@ -1066,18 +1066,18 @@ describe('App', () => { renderTable() mockPostMessage.mockClear() fireEvent.click(screen.getByLabelText('sorts')) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ type: MessageFromWebviewType.FOCUS_SORTS_TREE }) mockPostMessage.mockClear() fireEvent.click(screen.getByLabelText('filters')) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ type: MessageFromWebviewType.FOCUS_FILTERS_TREE }) mockPostMessage.mockClear() fireEvent.click(screen.getByLabelText('selected for plots')) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ type: MessageFromWebviewType.OPEN_PLOTS_WEBVIEW }) }) diff --git a/webview/src/experiments/components/table/Table.test.tsx b/webview/src/experiments/components/table/Table.test.tsx index 2922a35a36..0befccd1e2 100644 --- a/webview/src/experiments/components/table/Table.test.tsx +++ b/webview/src/experiments/components/table/Table.test.tsx @@ -195,7 +195,7 @@ describe('Table', () => { renderExperimentsTable() await clickOnSortOption(SortOrder.ASCENDING) - expect(mockedPostMessage).toBeCalledWith({ + expect(mockedPostMessage).toHaveBeenCalledWith({ payload: { descending: false, path: mockColumnPath @@ -220,7 +220,7 @@ describe('Table', () => { await clickOnSortOption(SortOrder.DESCENDING) - expect(mockedPostMessage).toBeCalledWith({ + expect(mockedPostMessage).toHaveBeenCalledWith({ payload: { descending: true, path: mockColumnPath @@ -245,7 +245,7 @@ describe('Table', () => { await clickOnSortOption(SortOrder.NONE) - expect(mockedPostMessage).toBeCalledWith({ + expect(mockedPostMessage).toHaveBeenCalledWith({ payload: mockColumnPath, type: MessageFromWebviewType.REMOVE_COLUMN_SORT }) @@ -375,7 +375,7 @@ describe('Table', () => { }) fireEvent.mouseUp(experimentColumnResizeHandle) - expect(mockedPostMessage).toBeCalledWith({ + expect(mockedPostMessage).toHaveBeenCalledWith({ payload: { id: 'id', width: 333 }, type: MessageFromWebviewType.RESIZE_COLUMN }) @@ -389,7 +389,7 @@ describe('Table', () => { fireEvent.mouseUp(experimentColumnResizeHandle) - expect(mockedPostMessage).toBeCalledWith({ + expect(mockedPostMessage).toHaveBeenCalledWith({ payload: { id: 'id', width: 353 }, type: MessageFromWebviewType.RESIZE_COLUMN }) diff --git a/webview/src/plots/components/App.test.tsx b/webview/src/plots/components/App.test.tsx index c976f24481..22d1b8a936 100644 --- a/webview/src/plots/components/App.test.tsx +++ b/webview/src/plots/components/App.test.tsx @@ -248,13 +248,13 @@ describe('App', () => { fireEvent.click(addPlotsButton) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ type: MessageFromWebviewType.SELECT_PLOTS }) mockPostMessage.mockReset() fireEvent.click(addExperimentsButton) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ type: MessageFromWebviewType.SELECT_EXPERIMENTS }) }) @@ -366,7 +366,7 @@ describe('App', () => { cancelable: true }) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ payload: { [Section.CHECKPOINT_PLOTS]: true }, type: MessageFromWebviewType.TOGGLE_PLOTS_SECTION }) @@ -407,7 +407,7 @@ describe('App', () => { cancelable: true }) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ payload: { [Section.CHECKPOINT_PLOTS]: true }, type: MessageFromWebviewType.TOGGLE_PLOTS_SECTION }) @@ -440,7 +440,7 @@ describe('App', () => { cancelable: true }) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ payload: { [Section.CHECKPOINT_PLOTS]: true }, type: MessageFromWebviewType.TOGGLE_PLOTS_SECTION }) @@ -503,7 +503,7 @@ describe('App', () => { cancelable: true }) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ payload: [ 'summary.json:accuracy', 'summary.json:val_accuracy', @@ -517,7 +517,7 @@ describe('App', () => { cancelable: true }) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ payload: [ 'summary.json:accuracy', 'summary.json:loss', @@ -571,7 +571,7 @@ describe('App', () => { const largeButton = screen.getByText('Large') fireEvent.click(largeButton) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ payload: { section: Section.CHECKPOINT_PLOTS, size: PlotSize.LARGE }, type: MessageFromWebviewType.RESIZE_PLOTS }) @@ -579,7 +579,7 @@ describe('App', () => { const smallButton = screen.getByText('Small') fireEvent.click(smallButton) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ payload: { section: Section.CHECKPOINT_PLOTS, size: PlotSize.SMALL }, type: MessageFromWebviewType.RESIZE_PLOTS }) @@ -597,7 +597,7 @@ describe('App', () => { const largeButton = screen.getByText('Large') fireEvent.click(largeButton) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ payload: { section: Section.CHECKPOINT_PLOTS, size: PlotSize.LARGE }, type: MessageFromWebviewType.RESIZE_PLOTS }) @@ -608,7 +608,7 @@ describe('App', () => { checkpoint: checkpointPlotsFixture }) - expect(mockPostMessage).not.toBeCalled() + expect(mockPostMessage).not.toHaveBeenCalled() }) it('should display the checkpoint plots in the order stored', () => { @@ -661,8 +661,8 @@ describe('App', () => { 'summary.json:val_accuracy' ] - expect(mockPostMessage).toBeCalledTimes(1) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledTimes(1) + expect(mockPostMessage).toHaveBeenCalledWith({ payload: expectedOrder, type: MessageFromWebviewType.REORDER_PLOTS_METRICS }) @@ -796,8 +796,8 @@ describe('App', () => { join('logs', 'loss.tsv'), join('other', 'multiview.tsv') ]) - expect(mockPostMessage).toBeCalledTimes(1) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledTimes(1) + expect(mockPostMessage).toHaveBeenCalledWith({ payload: [ { group: TemplatePlotGroup.SINGLE_VIEW, @@ -1707,7 +1707,7 @@ describe('App', () => { fireEvent.click(mainClearButton) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ payload: 'main', type: MessageFromWebviewType.TOGGLE_EXPERIMENT }) @@ -1737,7 +1737,7 @@ describe('App', () => { fireEvent.click(filterButton) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ type: MessageFromWebviewType.SELECT_EXPERIMENTS }) }) @@ -1757,7 +1757,7 @@ describe('App', () => { fireEvent.click(refreshAllButton) expect(mockPostMessage).toHaveBeenCalledTimes(1) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledWith({ payload: ['workspace', 'main', '4fb124a', '42b8736', '1ba7bcd'], type: MessageFromWebviewType.REFRESH_REVISIONS }) diff --git a/webview/src/plots/components/comparisonTable/ComparisonTable.test.tsx b/webview/src/plots/components/comparisonTable/ComparisonTable.test.tsx index 8c49a47ac1..3fe65dcbdb 100644 --- a/webview/src/plots/components/comparisonTable/ComparisonTable.test.tsx +++ b/webview/src/plots/components/comparisonTable/ComparisonTable.test.tsx @@ -133,8 +133,8 @@ describe('ComparisonTable', () => { expect(originalFirstColumn).not.toStrictEqual(currentFirstColumn) expect(originalFirstColumn).toStrictEqual(movedFirstColumn) - expect(mockPostMessage).toBeCalledTimes(1) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledTimes(1) + expect(mockPostMessage).toHaveBeenCalledWith({ payload: [ thirdExperiment, ...revisions.filter(rev => rev !== thirdExperiment) @@ -281,8 +281,8 @@ describe('ComparisonTable', () => { for (const button of refreshButtons) { fireEvent.click(button) - expect(mockPostMessage).toBeCalledTimes(1) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledTimes(1) + expect(mockPostMessage).toHaveBeenCalledWith({ payload: revisionWithNoData, type: MessageFromWebviewType.REFRESH_REVISION }) @@ -346,8 +346,8 @@ describe('ComparisonTable', () => { ] expect(headers).toStrictEqual(expectedNamedRevisions) - expect(mockPostMessage).toBeCalledTimes(1) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledTimes(1) + expect(mockPostMessage).toHaveBeenCalledWith({ payload: expectedRevisions, type: MessageFromWebviewType.REORDER_PLOTS_COMPARISON }) @@ -564,8 +564,8 @@ describe('ComparisonTable', () => { const reorderedRows = screen.getAllByRole('rowgroup').slice(1) const newOrder = reorderedRows.map(row => row.id) - expect(mockPostMessage).toBeCalledTimes(1) - expect(mockPostMessage).toBeCalledWith({ + expect(mockPostMessage).toHaveBeenCalledTimes(1) + expect(mockPostMessage).toHaveBeenCalledWith({ payload: newOrder, type: MessageFromWebviewType.REORDER_PLOTS_COMPARISON_ROWS }) diff --git a/webview/src/shared/components/copyButton/CopyButton.test.tsx b/webview/src/shared/components/copyButton/CopyButton.test.tsx index 4296c7ef78..423ad71251 100644 --- a/webview/src/shared/components/copyButton/CopyButton.test.tsx +++ b/webview/src/shared/components/copyButton/CopyButton.test.tsx @@ -43,7 +43,7 @@ describe('CopyButton', () => { await screen.findByTitle(successStateTitle) - expect(mockWriteText).toBeCalledWith(exampleCopyText) + expect(mockWriteText).toHaveBeenCalledWith(exampleCopyText) act(() => { jest.advanceTimersByTime(1000) }) @@ -62,7 +62,7 @@ describe('CopyButton', () => { await screen.findByTitle(failureStateTitle) - expect(mockWriteText).toBeCalledWith(exampleCopyText) + expect(mockWriteText).toHaveBeenCalledWith(exampleCopyText) act(() => { jest.advanceTimersByTime(1000) })