forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
64ba3ab
commit 5d1c5fb
Showing
2 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/pythonEnvironments/creation/provider/condaUtils.unit.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { assert } from 'chai'; | ||
import * as sinon from 'sinon'; | ||
import { CancellationTokenSource } from 'vscode'; | ||
import * as windowApis from '../../../../client/common/vscodeApis/windowApis'; | ||
import { pickPythonVersion } from '../../../../client/pythonEnvironments/creation/provider/condaUtils'; | ||
|
||
suite('Conda Utils test', () => { | ||
let showQuickPickWithBackStub: sinon.SinonStub; | ||
|
||
setup(() => { | ||
showQuickPickWithBackStub = sinon.stub(windowApis, 'showQuickPickWithBack'); | ||
}); | ||
|
||
teardown(() => { | ||
sinon.restore(); | ||
}); | ||
|
||
test('No version selected or user pressed escape', async () => { | ||
showQuickPickWithBackStub.resolves(undefined); | ||
|
||
const actual = await pickPythonVersion(); | ||
assert.isUndefined(actual); | ||
}); | ||
|
||
test('User selected a version', async () => { | ||
showQuickPickWithBackStub.resolves({ label: 'Python', description: '3.10' }); | ||
|
||
const actual = await pickPythonVersion(); | ||
assert.equal(actual, '3.10'); | ||
}); | ||
|
||
test('With cancellation', async () => { | ||
const source = new CancellationTokenSource(); | ||
|
||
showQuickPickWithBackStub.callsFake(() => { | ||
source.cancel(); | ||
}); | ||
|
||
const actual = await pickPythonVersion(source.token); | ||
assert.isUndefined(actual); | ||
}); | ||
}); |