-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbundleList.test.ts
More file actions
56 lines (46 loc) · 1.88 KB
/
Copy pathbundleList.test.ts
File metadata and controls
56 lines (46 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Copyright (c) 2025, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { Config } from '@oclif/core';
import { TestContext, MockTestOrgData } from '@salesforce/core/testSetup';
import { expect } from 'chai';
import { PackageBundle } from '@salesforce/packaging';
import { stubSfCommandUx } from '@salesforce/sf-plugins-core';
import sinon from 'sinon';
import { BundleListCommand } from '../../../src/commands/package/bundles/list.js';
describe('force:bundle:list - tests', () => {
const $$ = new TestContext();
const testOrg = new MockTestOrgData();
let sfCommandStubs: ReturnType<typeof stubSfCommandUx>;
let listStub: sinon.SinonStub;
const config = new Config({ root: import.meta.url });
beforeEach(async () => {
await $$.stubAuths(testOrg);
await config.load();
sfCommandStubs = stubSfCommandUx($$.SANDBOX);
listStub = $$.SANDBOX.stub(PackageBundle, 'list');
});
afterEach(() => {
$$.restore();
});
it('should list a bundle', async () => {
const cmd = new BundleListCommand(['-v', testOrg.username], config);
listStub.resolves([{ BundleName: 'test-bundle', Id: 'test-id', Description: 'test-description' }]);
await cmd.run();
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
expect(sfCommandStubs.table.calledOnce).to.be.true;
});
it('should throw error when test org flag is missing', async () => {
const cmd = new BundleListCommand([], config);
listStub.resolves([{ BundleName: 'test-bundle', Id: 'test-id', Description: 'test-description' }]);
try {
await cmd.run();
expect.fail('Expected error was not thrown');
} catch (error) {
expect((error as Error).message).to.include('No default dev hub found');
}
});
});