diff --git a/package.json b/package.json index c7f9bc3d..328d5712 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dependencies": { "@inquirer/checkbox": "^1.5.2", "@inquirer/select": "^1.3.3", - "@oclif/core": "^3.25.2", + "@oclif/core": "^3.26.0", "@salesforce/core": "^6.7.6", "@salesforce/plugin-info": "^3.0.28", "@salesforce/kit": "^3.1.0", diff --git a/test/commands/org/list/auth.test.ts b/test/commands/org/list/auth.test.ts index c286a145..fe0466a2 100644 --- a/test/commands/org/list/auth.test.ts +++ b/test/commands/org/list/auth.test.ts @@ -6,9 +6,9 @@ */ import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup.js'; -import { Config } from '@oclif/core'; import { expect } from 'chai'; import { AuthInfo } from '@salesforce/core'; +import { stubUx } from '@salesforce/sf-plugins-core'; import ListAuth from '../../../../src/commands/org/list/auth.js'; describe('org:list:auth', () => { @@ -22,12 +22,12 @@ describe('org:list:auth', () => { if (forceFailure) { $$.SANDBOX.stub(AuthInfo, 'create').throws(new Error('decrypt error')); } + stubUx($$.SANDBOX); } it('should show auth files', async () => { await prepareStubs(); - const list = new ListAuth(['--json'], {} as Config); - const [auths] = await list.run(); + const [auths] = await ListAuth.run(['--json']); expect(auths.alias).to.deep.equal(testData.aliases?.join(',') ?? ''); expect(auths.username).to.equal(testData.username); expect(auths.instanceUrl).to.equal(testData.instanceUrl); @@ -37,8 +37,7 @@ describe('org:list:auth', () => { it('should show files with auth errors', async () => { await prepareStubs(true); - const list = new ListAuth(['--json'], {} as Config); - const [auths] = await list.run(); + const [auths] = await ListAuth.run(['--json']); expect(auths.alias).to.deep.equal(testData.aliases?.join(',') ?? ''); expect(auths.username).to.equal(testData.username); expect(auths.instanceUrl).to.equal(testData.instanceUrl); diff --git a/test/commands/org/login/login.device.test.ts b/test/commands/org/login/login.device.test.ts index aa73161e..8e2cb754 100644 --- a/test/commands/org/login/login.device.test.ts +++ b/test/commands/org/login/login.device.test.ts @@ -12,8 +12,7 @@ import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup.js' import { StubbedType, stubInterface, stubMethod } from '@salesforce/ts-sinon'; import { DeviceCodeResponse } from '@salesforce/core/lib/deviceOauthService.js'; import { expect } from 'chai'; -import { Config } from '@oclif/core'; -import { SfCommand } from '@salesforce/sf-plugins-core'; +import { SfCommand, stubUx } from '@salesforce/sf-plugins-core'; import Login from '../../../../src/commands/org/login/device.js'; interface Options { approvalTimesout?: boolean; @@ -65,42 +64,39 @@ describe('org:login:device', () => { stubMethod($$.SANDBOX, AuthInfo, 'create').resolves(authInfoStub); await $$.stubAuths(testData); + stubUx($$.SANDBOX); + stubMethod($$.SANDBOX, SfCommand.prototype, 'logSuccess'); } it('should return auth fields', async () => { await prepareStubs(); - const login = new Login(['--json'], {} as Config); - const response = await login.run(); + const response = await Login.run(['--json']); expect(response.username).to.equal(testData.username); }); it('should return auth fields with instance url', async () => { await prepareStubs(); - const login = new Login(['-r', 'https://login.salesforce.com', '--json'], {} as Config); - const response = await login.run(); + const response = await Login.run(['-r', 'https://login.salesforce.com', '--json']); expect(response.username).to.equal(testData.username); }); it('should set alias when -a is provided', async () => { await prepareStubs(); - const login = new Login(['-a', 'MyAlias', '--json'], {} as Config); - const response = await login.run(); + const response = await Login.run(['-a', 'MyAlias', '--json']); expect(response.username).to.equal(testData.username); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); }); it('should set target-org when -s is provided', async () => { await prepareStubs(); - const login = new Login(['-s', '--json'], {} as Config); - const response = await login.run(); + const response = await Login.run(['-s', '--json']); expect(response.username).to.equal(testData.username); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); }); it('should set target-dev-hub when -d is provided', async () => { await prepareStubs(); - const login = new Login(['-d', '--json'], {} as Config); - const response = await login.run(); + const response = await Login.run(['-d', '--json']); expect(response.username).to.equal(testData.username); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); }); @@ -109,17 +105,15 @@ describe('org:login:device', () => { await prepareStubs(); const styledHeaderSpy = $$.SANDBOX.spy(SfCommand.prototype, 'styledHeader'); const logSpy = $$.SANDBOX.spy(SfCommand.prototype, 'log'); - const login = new Login([], {} as Config); - await login.run(); + await Login.run([]); expect(styledHeaderSpy.calledOnce).to.be.true; expect(logSpy.callCount).to.be.greaterThan(0); }); it('should gracefully handle approval timeout', async () => { await prepareStubs({ approvalTimesout: true }); - const login = new Login(['--json'], {} as Config); try { - const response = await login.run(); + const response = await Login.run(['--json']); expect.fail(`should have thrown: ${JSON.stringify(response)}`); } catch (e) { expect((e as Error).name).to.equal('polling timeout'); @@ -128,16 +122,14 @@ describe('org:login:device', () => { it('should gracefully handle failed approval', async () => { await prepareStubs({ approvalFails: true }); - const login = new Login(['--json'], {} as Config); - const response = await login.run(); + const response = await Login.run(['--json']); expect(response).to.deep.equal({}); }); it('should prompt for client secret if client id is provided', async () => { await prepareStubs(); $$.SANDBOX.stub(SfCommand.prototype, 'secretPrompt').resolves('1234'); - const login = new Login(['-i', 'CoffeeBeans', '--json'], {} as Config); - const response = await login.run(); + const response = await Login.run(['-i', 'CoffeeBeans', '--json']); expect(response.username).to.equal(testData.username); }); }); diff --git a/test/commands/org/login/login.jwt.test.ts b/test/commands/org/login/login.jwt.test.ts index b679e2e4..3b5e946d 100644 --- a/test/commands/org/login/login.jwt.test.ts +++ b/test/commands/org/login/login.jwt.test.ts @@ -9,7 +9,7 @@ import { AuthFields, AuthInfo, SfError } from '@salesforce/core'; import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup.js'; import { StubbedType, stubInterface } from '@salesforce/ts-sinon'; import { expect } from 'chai'; -import { Config } from '@oclif/core'; +import { stubUx } from '@salesforce/sf-plugins-core'; import LoginJwt from '../../../../src/commands/org/login/jwt.js'; interface Options { @@ -49,35 +49,36 @@ describe('org:login:jwt', () => { // @ts-ignore $$.SANDBOX.stub(AuthInfo, 'create').resolves(authInfoStub); } + + stubUx($$.SANDBOX); } it('should return auth fields', async () => { await prepareStubs(); - const grant = new LoginJwt( - ['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '--json'], - {} as Config - ); - const response = await grant.run(); + const response = await LoginJwt.run(['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '--json']); expect(response.username).to.equal(testData.username); }); it('should set alias when -a is provided', async () => { await prepareStubs(); - const grant = new LoginJwt( - ['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '-a', 'MyAlias', '--json'], - {} as Config - ); - await grant.run(); + await LoginJwt.run(['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '-a', 'MyAlias', '--json']); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); }); it('should set target-org to alias when -s and -a are provided', async () => { await prepareStubs(); - const grant = new LoginJwt( - ['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '-a', 'MyAlias', '-s', '--json'], - {} as Config - ); - await grant.run(); + await LoginJwt.run([ + '-u', + testData.username, + '-f', + 'path/to/key.json', + '-i', + '123456', + '-a', + 'MyAlias', + '-s', + '--json', + ]); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); expect(authInfoStub.handleAliasAndDefaultSettings.args[0]).to.deep.equal([ { @@ -90,11 +91,7 @@ describe('org:login:jwt', () => { it('should set target-org to username when -s is provided', async () => { await prepareStubs(); - const grant = new LoginJwt( - ['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '-s', '--json'], - {} as Config - ); - await grant.run(); + await LoginJwt.run(['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '-s', '--json']); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); expect(authInfoStub.handleAliasAndDefaultSettings.args[0]).to.deep.equal([ { @@ -107,11 +104,18 @@ describe('org:login:jwt', () => { it('should set target-dev-hub to alias when -d and -a are provided', async () => { await prepareStubs(); - const grant = new LoginJwt( - ['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '-a', 'MyAlias', '-d', '--json'], - {} as Config - ); - await grant.run(); + await LoginJwt.run([ + '-u', + testData.username, + '-f', + 'path/to/key.json', + '-i', + '123456', + '-a', + 'MyAlias', + '-d', + '--json', + ]); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); expect(authInfoStub.handleAliasAndDefaultSettings.args[0]).to.deep.equal([ { @@ -124,11 +128,7 @@ describe('org:login:jwt', () => { it('should set target-dev-hub to username when -d is provided', async () => { await prepareStubs(); - const grant = new LoginJwt( - ['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '-d', '--json'], - {} as Config - ); - await grant.run(); + await LoginJwt.run(['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '-d', '--json']); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); expect(authInfoStub.handleAliasAndDefaultSettings.args[0]).to.deep.equal([ { @@ -141,11 +141,7 @@ describe('org:login:jwt', () => { it('should set target-org and target-dev-hub to username when -d and -s are provided', async () => { await prepareStubs(); - const grant = new LoginJwt( - ['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '-d', '-s', '--json'], - {} as Config - ); - await grant.run(); + await LoginJwt.run(['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '-d', '-s', '--json']); expect(authInfoStub.setAlias.callCount).to.equal(0); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); expect(authInfoStub.handleAliasAndDefaultSettings.args[0]).to.deep.equal([ @@ -159,11 +155,19 @@ describe('org:login:jwt', () => { it('should set target-org and target-dev-hub to alias when -a, -d, and -s are provided', async () => { await prepareStubs(); - const grant = new LoginJwt( - ['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '-d', '-s', '-a', 'MyAlias', '--json'], - {} as Config - ); - await grant.run(); + await LoginJwt.run([ + '-u', + testData.username, + '-f', + 'path/to/key.json', + '-i', + '123456', + '-d', + '-s', + '-a', + 'MyAlias', + '--json', + ]); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); expect(authInfoStub.handleAliasAndDefaultSettings.args[0]).to.deep.equal([ { @@ -176,12 +180,8 @@ describe('org:login:jwt', () => { it('should throw an error when client id is invalid', async () => { await prepareStubs({ authInfoCreateFails: true }); - const grant = new LoginJwt( - ['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456INVALID', '--json'], - {} as Config - ); try { - await grant.run(); + await LoginJwt.run(['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456INVALID', '--json']); expect.fail('Should have thrown an error'); } catch (e) { expect((e as Error).message).to.include('We encountered a JSON web token error'); @@ -190,12 +190,8 @@ describe('org:login:jwt', () => { it('should not throw an error when the authorization already exists', async () => { await prepareStubs({ existingAuth: true }); - const grant = new LoginJwt( - ['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '--json'], - {} as Config - ); try { - await grant.run(); + await LoginJwt.run(['-u', testData.username, '-f', 'path/to/key.json', '-i', '123456', '--json']); } catch (e) { expect.fail('Should not have thrown an error'); } diff --git a/test/commands/org/login/login.sfdx-url.test.ts b/test/commands/org/login/login.sfdx-url.test.ts index 8d727c63..ac1731b4 100644 --- a/test/commands/org/login/login.sfdx-url.test.ts +++ b/test/commands/org/login/login.sfdx-url.test.ts @@ -9,8 +9,8 @@ import fs from 'node:fs/promises'; import { AuthFields, AuthInfo } from '@salesforce/core'; import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup.js'; import { expect } from 'chai'; -import { Config } from '@oclif/core'; import { StubbedType, stubInterface, stubMethod } from '@salesforce/ts-sinon'; +import { stubUx } from '@salesforce/sf-plugins-core'; import LoginSfdxUrl from '../../../../src/commands/org/login/sfdx-url.js'; interface Options { @@ -52,12 +52,13 @@ describe('org:login:sfdx-url', () => { // @ts-ignore $$.SANDBOX.stub(AuthInfo, 'create').resolves(authInfoStub); } + + stubUx($$.SANDBOX); } it('should return auth fields', async () => { await prepareStubs(); - const store = new LoginSfdxUrl(['-f', keyPathTxt, '--json'], {} as Config); - const response = await store.run(); + const response = await LoginSfdxUrl.run(['-f', keyPathTxt, '--json']); expect(response.username).to.equal(testData.username); }); @@ -72,22 +73,23 @@ describe('org:login:sfdx-url', () => { }) ); - const store = new LoginSfdxUrl(['-f', keyPathJson, '--json'], {} as Config); - const response = await store.run(); + const response = await LoginSfdxUrl.run(['-f', keyPathJson, '--json']); expect(response.username).to.equal(testData.username); }); it("should error out when it doesn't find a url in a JSON file", async () => { await prepareStubs({ fileDoesNotExist: true }); - $$.SANDBOX.stub(fs, 'readFile').resolves( - JSON.stringify({ - notASfdxAuthUrl: 'force://PlatformCLI::CoffeeAndBacon@su0503.my.salesforce.com', - }) - ); + $$.SANDBOX.stub(fs, 'readFile') + .callThrough() + .withArgs(keyPathJson, 'utf8') + .resolves( + JSON.stringify({ + notASfdxAuthUrl: 'force://PlatformCLI::CoffeeAndBacon@su0503.my.salesforce.com', + }) + ); - const store = new LoginSfdxUrl(['-f', keyPathJson, '--json'], {} as Config); try { - const response = await store.run(); + const response = await LoginSfdxUrl.run(['-f', keyPathJson, '--json']); expect.fail(`Should have thrown an error. Response: ${JSON.stringify(response)}`); } catch (e) { expect((e as Error).message).to.includes('Error getting the auth URL from file'); @@ -96,15 +98,13 @@ describe('org:login:sfdx-url', () => { it('should set alias when -a is provided', async () => { await prepareStubs(); - const store = new LoginSfdxUrl(['-f', keyPathTxt, '-a', 'MyAlias', '--json'], {} as Config); - await store.run(); + await LoginSfdxUrl.run(['-f', keyPathTxt, '-a', 'MyAlias', '--json']); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); }); it('should set target-org to alias when -s and -a are provided', async () => { await prepareStubs(); - const store = new LoginSfdxUrl(['-f', keyPathTxt, '-a', 'MyAlias', '-s', '--json'], {} as Config); - await store.run(); + await LoginSfdxUrl.run(['-f', keyPathTxt, '-a', 'MyAlias', '-s', '--json']); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); expect(authInfoStub.handleAliasAndDefaultSettings.args[0]).to.deep.equal([ { @@ -117,8 +117,7 @@ describe('org:login:sfdx-url', () => { it('should set target-org to username when -s is provided', async () => { await prepareStubs(); - const store = new LoginSfdxUrl(['-f', keyPathTxt, '-s', '--json'], {} as Config); - await store.run(); + await LoginSfdxUrl.run(['-f', keyPathTxt, '-s', '--json']); expect(authInfoStub.setAlias.callCount).to.equal(0); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); expect(authInfoStub.handleAliasAndDefaultSettings.args[0]).to.deep.equal([ @@ -132,8 +131,7 @@ describe('org:login:sfdx-url', () => { it('should set target-dev-hub to alias when -d and -a are provided', async () => { await prepareStubs(); - const store = new LoginSfdxUrl(['-f', keyPathTxt, '-a', 'MyAlias', '-d', '--json'], {} as Config); - await store.run(); + await LoginSfdxUrl.run(['-f', keyPathTxt, '-a', 'MyAlias', '-d', '--json']); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); expect(authInfoStub.handleAliasAndDefaultSettings.args[0]).to.deep.equal([ { @@ -146,8 +144,7 @@ describe('org:login:sfdx-url', () => { it('should set target-dev-hub to username when -d is provided', async () => { await prepareStubs(); - const store = new LoginSfdxUrl(['-f', keyPathTxt, '-d', '--json'], {} as Config); - await store.run(); + await LoginSfdxUrl.run(['-f', keyPathTxt, '-d', '--json']); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); expect(authInfoStub.handleAliasAndDefaultSettings.args[0]).to.deep.equal([ { @@ -160,8 +157,7 @@ describe('org:login:sfdx-url', () => { it('should set target-org and target-dev-hub to username when -d and -s are provided', async () => { await prepareStubs(); - const store = new LoginSfdxUrl(['-f', keyPathTxt, '-d', '-s', '--json'], {} as Config); - await store.run(); + await LoginSfdxUrl.run(['-f', keyPathTxt, '-d', '-s', '--json']); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); expect(authInfoStub.handleAliasAndDefaultSettings.args[0]).to.deep.equal([ { @@ -174,8 +170,7 @@ describe('org:login:sfdx-url', () => { it('should set target-org and target-dev-hub to alias when -a, -d, and -s are provided', async () => { await prepareStubs(); - const store = new LoginSfdxUrl(['-f', keyPathTxt, '-d', '-s', '-a', 'MyAlias', '--json'], {} as Config); - await store.run(); + await LoginSfdxUrl.run(['-f', keyPathTxt, '-d', '-s', '-a', 'MyAlias', '--json']); expect(authInfoStub.handleAliasAndDefaultSettings.callCount).to.equal(1); expect(authInfoStub.handleAliasAndDefaultSettings.args[0]).to.deep.equal([ { @@ -188,9 +183,8 @@ describe('org:login:sfdx-url', () => { it('should error out when neither file or url are provided', async () => { await prepareStubs(); - const store = new LoginSfdxUrl([], {} as Config); try { - const response = await store.run(); + const response = await LoginSfdxUrl.run([]); expect.fail(`Should have thrown an error. Response: ${JSON.stringify(response)}`); } catch (e) { expect((e as Error).message).to.includes( @@ -209,9 +203,8 @@ describe('org:login:sfdx-url', () => { 'sfdx-url-stdin': sfdxAuthUrl, }, }; - const store = new LoginSfdxUrl(['-u', '-'], {} as Config); - stubMethod($$.SANDBOX, store, 'parse').resolves(flagOutput); - const response = await store.run(); + stubMethod($$.SANDBOX, LoginSfdxUrl.prototype, 'parse').resolves(flagOutput); + const response = await LoginSfdxUrl.run(['-u', '-']); expect(response.username).to.equal(testData.username); }); }); diff --git a/test/commands/org/login/login.web.test.ts b/test/commands/org/login/login.web.test.ts index 8e23e556..1b58db94 100644 --- a/test/commands/org/login/login.web.test.ts +++ b/test/commands/org/login/login.web.test.ts @@ -19,7 +19,13 @@ import LoginWeb from '../../../../src/commands/org/login/web.js'; describe('org:login:web', () => { const $$ = new TestContext(); const testData = new MockTestOrgData(); - const config = stubInterface($$.SANDBOX, {}); + const config = stubInterface($$.SANDBOX, { + runHook: async () => + Promise.resolve({ + successes: [], + failures: [], + }), + }); let authFields: AuthFields; let authInfoStub: StubbedType; let uxStub: StubbedType; diff --git a/test/commands/org/logout.test.ts b/test/commands/org/logout.test.ts index c6d7ea3a..2a62322f 100644 --- a/test/commands/org/logout.test.ts +++ b/test/commands/org/logout.test.ts @@ -8,8 +8,7 @@ import { AuthRemover, ConfigContents, Global, Mode, Messages } from '@salesforce/core'; import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup.js'; import { expect } from 'chai'; -import { Config } from '@oclif/core'; -import { stubPrompter } from '@salesforce/sf-plugins-core'; +import { stubPrompter, stubUx } from '@salesforce/sf-plugins-core'; import Logout from '../../../src/commands/org/logout.js'; Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); @@ -52,14 +51,16 @@ describe('org:logout', () => { if (options.aliases) { $$.stubAliases(options.aliases); } + + stubUx($$.SANDBOX); + return authInfo; } it('should throw error when both -a and -o are specified', async () => { await prepareStubs(); - const logout = new Logout(['-a', '-o', testOrg1.username, '--json'], {} as Config); try { - await logout.run(); + await Logout.run(['-a', '-o', testOrg1.username, '--json']); } catch (e) { const error = e as Error; expect(error.name).to.equal('Error'); @@ -69,8 +70,7 @@ describe('org:logout', () => { it('should remove target-org when neither -a nor -o are specified', async () => { await prepareStubs({ 'target-org': testOrg1.username }); - const logout = new Logout(['-p', '--json'], {} as Config); - const response = await logout.run(); + const response = await Logout.run(['-p', '--json']); expect(response).to.deep.equal([testOrg1.username]); expect(authRemoverSpy.callCount).to.equal(1); @@ -78,16 +78,14 @@ describe('org:logout', () => { it('should remove username specified by -o', async () => { await prepareStubs({ 'target-org': testOrg1.username }); - const logout = new Logout(['-p', '-o', testOrg1.username, '--json'], {} as Config); - const response = await logout.run(); + const response = await Logout.run(['-p', '-o', testOrg1.username, '--json']); expect(response).to.deep.equal([testOrg1.username]); expect(authRemoverSpy.callCount).to.equal(1); }); it('should remove all usernames when -a is specified', async () => { await prepareStubs(); - const logout = new Logout(['-p', '-a', '--json'], {} as Config); - const response = await logout.run(); + const response = await Logout.run(['-p', '-a', '--json']); expect(response).to.deep.equal([testOrg1.username, testOrg2.username, testOrg3.username]); expect(authRemoverSpy.callCount).to.equal(3); }); @@ -95,17 +93,15 @@ describe('org:logout', () => { it('should remove all usernames when in demo mode', async () => { await prepareStubs(); $$.SANDBOX.stub(Global, 'getEnvironmentMode').returns(Mode.DEMO); - const logout = new Logout(['-p', '-a', '--json'], {} as Config); - const response = await logout.run(); + const response = await Logout.run(['-p', '-a', '--json']); expect(response).to.deep.equal([testOrg1.username, testOrg2.username, testOrg3.username]); expect(authRemoverSpy.callCount).to.equal(3); }); it('should throw error if no target-org', async () => { await prepareStubs(); - const logout = new Logout(['-p', '--json'], {} as Config); try { - const response = await logout.run(); + const response = await Logout.run(['-p', '--json']); expect.fail(`should have thrown error. Response: ${JSON.stringify(response)}`); } catch (e) { expect((e as Error).name).to.equal('NoOrgSpecifiedWithNoPromptError'); @@ -117,8 +113,7 @@ describe('org:logout', () => { it('shows correct prompt for single org', async () => { await prepareStubs(); promptStub.confirm.resolves(false); - const logout = new Logout(['-o', testOrg1.username], {} as Config); - await logout.run(); + await Logout.run(['-o', testOrg1.username]); expect(promptStub.confirm.args[0][0].message).to.equal( messages.getMessage('prompt.confirm.single', [testOrg1.username]) ); @@ -126,16 +121,14 @@ describe('org:logout', () => { it('should do nothing when prompt is answered with no', async () => { await prepareStubs(); promptStub.confirm.resolves(false); - const logout = new Logout(['-o', testOrg1.username], {} as Config); - const response = await logout.run(); + const response = await Logout.run(['-o', testOrg1.username]); expect(response).to.deep.equal([]); }); }); it('should remove auth when alias is specified', async () => { await prepareStubs({ aliases: { TestAlias: testOrg1.username } }); - const logout = new Logout(['-p', '-o', 'TestAlias', '--json'], {} as Config); - const response = await logout.run(); + const response = await Logout.run(['-p', '-o', 'TestAlias', '--json']); expect(response).to.deep.equal([testOrg1.username]); }); @@ -145,8 +138,7 @@ describe('org:logout', () => { 'target-dev-hub': 'TestAlias', aliases: { TestAlias: testOrg1.username }, }); - const logout = new Logout(['-p', '--json'], {} as Config); - const response = await logout.run(); + const response = await Logout.run(['-p', '--json']); expect(response).to.deep.equal([testOrg1.username]); }); @@ -155,8 +147,7 @@ describe('org:logout', () => { 'target-org': 'TestAlias', aliases: { TestAlias: testOrg1.username }, }); - const logout = new Logout(['-p', '--json'], {} as Config); - const response = await logout.run(); + const response = await Logout.run(['-p', '--json']); expect(response).to.deep.equal([testOrg1.username]); }); @@ -166,8 +157,7 @@ describe('org:logout', () => { aliases: { TestAlias: testOrg1.username }, authInfoConfigDoesNotExist: true, }); - const logout = new Logout(['-p', '-o', testOrg1.username, '--json'], {} as Config); - const response = await logout.run(); + const response = await Logout.run(['-p', '-o', testOrg1.username, '--json']); expect(response).to.deep.equal([testOrg1.username]); }); }); diff --git a/yarn.lock b/yarn.lock index 2190ed1a..ab2f1dba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1351,7 +1351,7 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@oclif/core@3.25.2", "@oclif/core@^3.15.1", "@oclif/core@^3.19.2", "@oclif/core@^3.20.0", "@oclif/core@^3.21.0", "@oclif/core@^3.23.0", "@oclif/core@^3.25.2": +"@oclif/core@3.25.2": version "3.25.2" resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.25.2.tgz#a26d56abe5686c57c1e973957777bd2ae324e973" integrity sha512-OkW/cNa/3DhoCz2YlSpymVe8DXqkoRaLY4SPTVqNVzR4R1dFBE5KoCtuwKwnhxYLCRCqaViPgRnB5K26f0MnjA== @@ -1385,40 +1385,7 @@ wordwrap "^1.0.0" wrap-ansi "^7.0.0" -"@oclif/core@^3.19.1": - version "3.20.0" - resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.20.0.tgz#534458dc6e8c46d8f03906aaadaca079e16a6554" - integrity sha512-8BajhglY8frYGAS1whAukeouFZUN9MgQoLfNXtScPVEAjPlaD2BbSIAYQH2yF2qb/iVvbj/1DwYS3gqicYOq1A== - dependencies: - "@types/cli-progress" "^3.11.5" - ansi-escapes "^4.3.2" - ansi-styles "^4.3.0" - cardinal "^2.1.1" - chalk "^4.1.2" - clean-stack "^3.0.1" - cli-progress "^3.12.0" - color "^4.2.3" - debug "^4.3.4" - ejs "^3.1.9" - get-package-type "^0.1.0" - globby "^11.1.0" - hyperlinker "^1.0.0" - indent-string "^4.0.0" - is-wsl "^2.2.0" - js-yaml "^3.14.1" - natural-orderby "^2.0.3" - object-treeify "^1.1.33" - password-prompt "^1.1.3" - slice-ansi "^4.0.0" - string-width "^4.2.3" - strip-ansi "^6.0.1" - supports-color "^8.1.1" - supports-hyperlinks "^2.2.0" - widest-line "^3.1.0" - wordwrap "^1.0.0" - wrap-ansi "^7.0.0" - -"@oclif/core@^3.19.6": +"@oclif/core@^3.15.1", "@oclif/core@^3.19.1", "@oclif/core@^3.19.2", "@oclif/core@^3.19.6", "@oclif/core@^3.20.0", "@oclif/core@^3.21.0", "@oclif/core@^3.23.0", "@oclif/core@^3.26.0": version "3.26.0" resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.26.0.tgz#959d5e9f13f4ad6a4e98235ad125189df9ee4279" integrity sha512-TpMdfD4tfA2tVVbd4l0PrP02o5KoUXYmudBbTC7CeguDo/GLoprw4uL8cMsaVA26+cbcy7WYtOEydQiHVtJixA==