-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbase-command.integration.test.ts
More file actions
59 lines (49 loc) · 2.15 KB
/
base-command.integration.test.ts
File metadata and controls
59 lines (49 loc) · 2.15 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
57
58
59
/*
* Copyright (c) 2025, Salesforce, Inc.
* SPDX-License-Identifier: Apache-2
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
*/
import {expect} from 'chai';
import {runCommand} from '@oclif/test';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const fixtureRoot = path.join(__dirname, '../fixtures/test-cli');
describe('BaseCommand integration', () => {
it('runs test-base command without errors', async () => {
const {error} = await runCommand(['test-base'], {root: fixtureRoot});
expect(error).to.be.undefined;
});
it('handles --extra-query flag', async () => {
const {error, result} = await runCommand<{extraParams?: Record<string, unknown>}>(
['test-base', '--extra-query', '{"debug":"true"}', '--json'],
{root: fixtureRoot},
);
expect(error).to.be.undefined;
expect(result?.extraParams?.query).to.deep.equal({debug: 'true'});
});
it('handles --extra-body flag', async () => {
const {error, result} = await runCommand<{extraParams?: Record<string, unknown>}>(
['test-base', '--extra-body', '{"_internal":true}', '--json'],
{root: fixtureRoot},
);
expect(error).to.be.undefined;
expect(result?.extraParams?.body).to.deep.equal({_internal: true});
});
it('handles both --extra-query and --extra-body flags', async () => {
const {error, result} = await runCommand<{extraParams?: Record<string, unknown>}>(
['test-base', '--extra-query', '{"debug":"true"}', '--extra-body', '{"_internal":true}', '--json'],
{root: fixtureRoot},
);
expect(error).to.be.undefined;
expect(result?.extraParams?.query).to.deep.equal({debug: 'true'});
expect(result?.extraParams?.body).to.deep.equal({_internal: true});
});
it('returns undefined extraParams when no extra flags provided', async () => {
const {error, result} = await runCommand<{extraParams?: Record<string, unknown>}>(['test-base', '--json'], {
root: fixtureRoot,
});
expect(error).to.be.undefined;
expect(result?.extraParams).to.be.undefined;
});
});