Have forceNewSession behave like createIfNone if no sessions are present (#148819)

* Have forceNewSession behave like createIfNone if no sessions are present

* include note in vscode.d.ts about forceNewSesssion behavior
This commit is contained in:
Tyler James Leonhardt
2022-05-05 13:30:14 -07:00
committed by GitHub
parent 9991dffebf
commit 6c8d8a2654
3 changed files with 24 additions and 21 deletions

View File

@@ -211,7 +211,7 @@ suite('ExtHostAuthentication', () => {
assert.strictEqual(session.scopes[0], session2?.scopes[0]);
});
test('forceNewSession - true', async () => {
test('forceNewSession - true - existing session', async () => {
const scopes = ['foo'];
const session1 = await extHostAuthentication.getSession(
extensionDescription,
@@ -235,6 +235,20 @@ suite('ExtHostAuthentication', () => {
assert.notStrictEqual(session1.accessToken, session2?.accessToken);
});
// Should behave like createIfNone: true
test('forceNewSession - true - no existing session', async () => {
const scopes = ['foo'];
const session = await extHostAuthentication.getSession(
extensionDescription,
'test',
scopes,
{
forceNewSession: true
});
assert.strictEqual(session?.id, '1');
assert.strictEqual(session?.scopes[0], 'foo');
});
test('forceNewSession - detail', async () => {
const scopes = ['foo'];
const session1 = await extHostAuthentication.getSession(
@@ -350,21 +364,6 @@ suite('ExtHostAuthentication', () => {
//#region error cases
test('forceNewSession with no sessions', async () => {
try {
await extHostAuthentication.getSession(
extensionDescription,
'test',
['foo'],
{
forceNewSession: true
});
assert.fail('should have thrown an Error.');
} catch (e) {
assert.strictEqual(e.message, 'No existing sessions found.');
}
});
test('createIfNone and forceNewSession', async () => {
try {
await extHostAuthentication.getSession(