File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed
packages/cli-test/src/cli Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
Original file line number Diff line number Diff line change 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+ } ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import func from './commands/function';
1414import manifest from './commands/manifest' ;
1515import platform from './commands/platform' ;
1616import 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
You can’t perform that action at this time.
0 commit comments