Skip to content

Commit 54d06c7

Browse files
authored
feat(cli-test): add version command (#2353)
1 parent 18c4af4 commit 54d06c7

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import sinon from 'sinon';
2+
3+
import { mockProcess } from '../../utils/test';
4+
import { shell } from '../shell';
5+
import version from './version';
6+
7+
describe('version commands', () => {
8+
const sandbox = sinon.createSandbox();
9+
let spawnSpy: sinon.SinonStub;
10+
11+
beforeEach(() => {
12+
const process = mockProcess();
13+
spawnSpy = sandbox.stub(shell, 'spawnProcess').returns({
14+
command: 'version',
15+
finished: true,
16+
output: 'Using slack v3.4.5',
17+
process,
18+
});
19+
sandbox.stub(shell, 'checkIfFinished').resolves();
20+
});
21+
afterEach(() => {
22+
sandbox.restore();
23+
});
24+
25+
describe('version method', () => {
26+
it('should invoke `version`', async () => {
27+
const actual = await version.version();
28+
sandbox.assert.calledWith(spawnSpy, sinon.match.string, sinon.match.array.contains(['version']));
29+
sinon.assert.match(actual, 'v3.4.5');
30+
});
31+
});
32+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { SlackCLIProcess } from '../cli-process';
2+
3+
/**
4+
* `slack version`
5+
* @returns command output
6+
*/
7+
export const version = async function version(): Promise<string> {
8+
const cmd = new SlackCLIProcess(['version']);
9+
const proc = await cmd.execAsync();
10+
return proc.output;
11+
};
12+
13+
export default {
14+
version,
15+
};

packages/cli-test/src/cli/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import func from './commands/function';
1414
import manifest from './commands/manifest';
1515
import platform from './commands/platform';
1616
import trigger from './commands/trigger';
17+
import version from './commands/version';
1718

1819
/**
1920
* Set of functions to spawn and interact with Slack Platform CLI processes and commands
@@ -30,6 +31,7 @@ export const SlackCLI = {
3031
manifest,
3132
platform,
3233
trigger,
34+
version,
3335

3436
/**
3537
* Delete app and Log out of current team session

0 commit comments

Comments
 (0)