Skip to content
This repository has been archived by the owner on Apr 23, 2022. It is now read-only.

test: add test case for iot workbench settings #930

Merged
merged 2 commits into from
Feb 27, 2020
Merged

test: add test case for iot workbench settings #930

merged 2 commits into from
Feb 27, 2020

Conversation

dilin-MS
Copy link
Contributor

No description provided.

__mocks__/vscode.js Outdated Show resolved Hide resolved
__mocks__/vscode.js Outdated Show resolved Hide resolved
test/IoTSettings.test.ts Outdated Show resolved Hide resolved
test/IoTSettings.test.ts Outdated Show resolved Hide resolved
test/IoTSettings.test.ts Outdated Show resolved Hide resolved
test/IoTSettings.test.ts Outdated Show resolved Hide resolved
test/IoTSettings.test.ts Outdated Show resolved Hide resolved
test/IoTSettings.test.ts Outdated Show resolved Hide resolved
const workbenchPathFromConfig = "workbench-path-from-config";
const defaultWorkbenchPath = "default-workbench-path";
configHandlerModule.ConfigHandler.get = jest.fn().mockReturnValueOnce(workbenchPathFromConfig);
IoTWorkbenchSettingsModule.IoTWorkbenchSettings.getDefaultWorkbenchPath = jest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are testing IoTWorkbenchSettings class, I recommend not mocking its self method, but mocking external dependency (e.g. getPlatform and getHomeDir) instead, to get desired value.


test("set workbench path", async () => {
const userWorkbenchPath = "user-workbench-path";
vscode.window.showQuickPick = jest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the mocked "showQuickPick" method return the first item in your code, which is the default behavior defined in "mocks/vscode.js". You can remove this mocking statement to see if it works.

@dilin-MS dilin-MS merged commit d22c636 into develop Feb 27, 2020
@dilin-MS dilin-MS deleted the add-test branch February 27, 2020 04:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants