-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli-test: small internal refactor to use new app.list command (#1797)
- Loading branch information
Showing
2 changed files
with
43 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import sinon from 'sinon'; | ||
import logger from '../utils/logger'; | ||
import { SlackCLI } from './index'; | ||
|
||
describe('cli module', () => { | ||
const sandbox = sinon.createSandbox(); | ||
let logoutSpy: sinon.SinonStub; | ||
let warnSpy: sinon.SinonStub; | ||
let deleteSpy: sinon.SinonStub; | ||
|
||
beforeEach(() => { | ||
logoutSpy = sandbox.stub(SlackCLI, 'logout').resolves(); | ||
warnSpy = sandbox.stub(logger, 'warn'); | ||
sandbox.stub(SlackCLI.app, 'list').resolves('This thing has so many apps you would not believe'); | ||
deleteSpy = sandbox.stub(SlackCLI.app, 'delete').resolves(); | ||
}); | ||
afterEach(() => { | ||
sandbox.restore(); | ||
}); | ||
|
||
describe('stopSession method', () => { | ||
it('should invoke logout', async () => { | ||
await SlackCLI.stopSession({ appTeamID: 'T123' }); | ||
sandbox.assert.called(logoutSpy); | ||
}); | ||
it('should warn if logout failed', async () => { | ||
logoutSpy.rejects('boomsies'); | ||
await SlackCLI.stopSession({ appTeamID: 'T123' }); | ||
sandbox.assert.calledWithMatch(warnSpy, 'boomsies'); | ||
}); | ||
it('should attempt to delete app if appPath is provided', async () => { | ||
await SlackCLI.stopSession({ appTeamID: 'T123', appPath: '/some/path' }); | ||
sandbox.assert.called(deleteSpy); | ||
}); | ||
it('should warn if app deletion fails', async () => { | ||
deleteSpy.rejects('explosions'); | ||
await SlackCLI.stopSession({ appTeamID: 'T123', appPath: '/some/path' }); | ||
sandbox.assert.calledWithMatch(warnSpy, 'explosions'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters