Skip to content

Commit cb328b8

Browse files
committed
test: correct mocks on org:delete
1 parent b1879c2 commit cb328b8

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

test/unit/force/org/delete.test.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
import { ConfigAggregator, Messages, Org, SfError } from '@salesforce/core';
88
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup';
99

10-
import { expect } from 'chai';
10+
import { expect, config } from 'chai';
1111
import { stubPrompter, stubSfCommandUx } from '@salesforce/sf-plugins-core';
1212
import { SandboxAccessor } from '@salesforce/core/lib/stateAggregator/accessors/sandboxAccessor';
1313
import { Config } from '@oclif/core';
1414
import { Delete } from '../../../../src/commands/force/org/delete';
1515

16+
config.truncateThreshold = 0;
17+
1618
Messages.importMessagesDirectory(__dirname);
1719
const messages = Messages.loadMessages('@salesforce/plugin-org', 'delete');
1820

@@ -60,7 +62,7 @@ describe('org:delete', () => {
6062
});
6163

6264
it('will determine sandbox vs scratch org and delete sandbox', async () => {
63-
$$.SANDBOX.stub(SandboxAccessor.prototype, 'has').resolves(true);
65+
$$.SANDBOX.stub(SandboxAccessor.prototype, 'hasFile').resolves(true);
6466
const res = await Delete.run(['--target-org', testOrg.username]);
6567
expect(prompterStubs.confirm.calledOnce).to.equal(true);
6668
expect(prompterStubs.confirm.firstCall.args[0]).to.equal(
@@ -82,7 +84,7 @@ describe('org:delete', () => {
8284
});
8385

8486
it('will NOT prompt before deleting sandbox when flag is provided', async () => {
85-
$$.SANDBOX.stub(SandboxAccessor.prototype, 'has').resolves(true);
87+
$$.SANDBOX.stub(SandboxAccessor.prototype, 'hasFile').resolves(true);
8688
$$.SANDBOX.stub(Org.prototype, 'delete').resolves();
8789
const res = await Delete.run(['--noprompt', '--target-org', testOrg.username]);
8890
expect(prompterStubs.confirm.calledOnce).to.equal(false);
@@ -105,13 +107,14 @@ describe('org:delete', () => {
105107
});
106108

107109
it('will catch the SandboxNotFound and wrap correctly', async () => {
108-
$$.SANDBOX.stub(SandboxAccessor.prototype, 'has').resolves(true);
110+
$$.SANDBOX.stub(SandboxAccessor.prototype, 'hasFile').resolves(true);
109111
$$.SANDBOX.stub(Org.prototype, 'delete').throws(new SfError('bah!', 'SandboxNotFound'));
110112
const res = await Delete.run(['--noprompt', '--target-org', testOrg.username]);
111113
expect(prompterStubs.confirm.called).to.equal(false);
112114
expect(res).to.deep.equal({ orgId: testOrg.orgId, username: testOrg.username });
113-
expect(sfCommandUxStubs.log.getCalls().flatMap((call) => call.args)).to.deep.include(
114-
messages.getMessage('sandboxConfigOnlySuccess', [testOrg.username])
115-
);
115+
expect(
116+
sfCommandUxStubs.log.getCalls().flatMap((call) => call.args),
117+
JSON.stringify(sfCommandUxStubs.log.getCalls().flatMap((call) => call.args))
118+
).to.deep.include(messages.getMessage('sandboxConfigOnlySuccess', [testOrg.username]));
116119
});
117120
});

0 commit comments

Comments
 (0)