Skip to content

Commit ef5c4e8

Browse files
committed
test: for varargs
1 parent 49c9824 commit ef5c4e8

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

src/commands/force/org/clone.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export class OrgCloneCommand extends SfdxCommand {
3333
public static readonly description = messages.getMessage('description');
3434
public static readonly requiresProject = false;
3535
public static readonly requiresUsername = true;
36+
public static readonly varargs = true;
3637
public static readonly SANDBOXDEF_SRC_SANDBOXNAME = 'SourceSandboxName';
3738

3839
public static readonly flagsConfig: FlagsConfig = {

test/commands/force/org/clone.test.ts

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ describe('org:clone', () => {
6767
let configWriteStub: sinon.SinonStub;
6868
let onStub: sinon.SinonStub;
6969
let readFileSyncStub: sinon.SinonStub;
70+
let cloneSandboxStub: sinon.SinonStub;
7071
let configAggregatorStub;
7172

7273
class TestOrgCloneCommand extends OrgCloneCommand {
@@ -85,10 +86,11 @@ describe('org:clone', () => {
8586
const runCloneCommand = async (params: string[]) => {
8687
cmd = new TestOrgCloneCommand(params, oclifConfigStub);
8788
stubMethod(sandbox, cmd, 'assignOrg').callsFake(() => {
89+
cloneSandboxStub = sandbox.stub().callsFake(async () => {
90+
return sandboxProcessObj;
91+
});
8892
const orgStubOptions = {
89-
cloneSandbox: sandbox.stub().callsFake(async () => {
90-
return sandboxProcessObj;
91-
}),
93+
cloneSandbox: cloneSandboxStub,
9294
};
9395
const orgStub = fromStub(stubInterface<Org>(sandbox, orgStubOptions));
9496
cmd.setOrg(orgStub);
@@ -132,6 +134,39 @@ describe('org:clone', () => {
132134
expect(onStub.secondCall.firstArg).to.be.equal(SandboxEvents.EVENT_STATUS);
133135
expect(onStub.thirdCall.firstArg).to.be.equal(SandboxEvents.EVENT_RESULT);
134136
expect(onStub.callCount).to.be.equal(3);
137+
expect(cloneSandboxStub.firstCall.firstArg).to.deep.equal({
138+
LicenseType: 'Developer',
139+
SandboxName: 'newSandbox',
140+
});
141+
expect(res).to.deep.equal(sandboxProcessObj);
142+
});
143+
144+
it('will return sandbox process object varargs override defFile', async () => {
145+
const licenseType = 'Enterprise';
146+
const res = await runCloneCommand([
147+
'-t',
148+
'sandbox',
149+
'-u',
150+
'DevHub',
151+
'-f',
152+
'sandbox-def.json',
153+
`licenseType=${licenseType}`,
154+
]);
155+
expect(uxStyledHeaderStub.calledOnce).to.be.true;
156+
expect(uxTableStub.firstCall.args[0].length).to.be.equal(12);
157+
expect(readFileSyncStub.calledOnce).to.be.true;
158+
expect(uxLogStub.callCount).to.be.equal(3);
159+
expect(aliasSetStub.callCount).to.be.equal(0);
160+
expect(configSetStub.callCount).to.be.equal(0);
161+
expect(configWriteStub.callCount).to.be.equal(0);
162+
expect(onStub.firstCall.firstArg).to.be.equal(SandboxEvents.EVENT_ASYNC_RESULT);
163+
expect(onStub.secondCall.firstArg).to.be.equal(SandboxEvents.EVENT_STATUS);
164+
expect(onStub.thirdCall.firstArg).to.be.equal(SandboxEvents.EVENT_RESULT);
165+
expect(onStub.callCount).to.be.equal(3);
166+
expect(cloneSandboxStub.firstCall.firstArg).to.deep.equal({
167+
LicenseType: licenseType,
168+
SandboxName: 'newSandbox',
169+
});
135170
expect(res).to.deep.equal(sandboxProcessObj);
136171
});
137172

@@ -160,6 +195,10 @@ describe('org:clone', () => {
160195
expect(onStub.secondCall.firstArg).to.be.equal(SandboxEvents.EVENT_STATUS);
161196
expect(onStub.thirdCall.firstArg).to.be.equal(SandboxEvents.EVENT_RESULT);
162197
expect(onStub.callCount).to.be.equal(3);
198+
expect(cloneSandboxStub.firstCall.firstArg).to.deep.equal({
199+
LicenseType: 'Developer',
200+
SandboxName: 'newSandbox',
201+
});
163202
expect(configWriteStub.calledOnce).to.be.true;
164203
expect(res).to.deep.equal(sandboxProcessObj);
165204
});

0 commit comments

Comments
 (0)