Skip to content

Commit

Permalink
Fix slackapi#1068 Throw an error if both socketMode: boolean and rece…
Browse files Browse the repository at this point in the history
…iver: Receiver arguments in App constructor
  • Loading branch information
seratch committed Aug 24, 2021
1 parent 0ad0e89 commit f6c26af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/App.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,21 @@ describe('App', () => {
assert.propertyVal(error, 'code', ErrorCode.AppInitializationError);
}
});
it('should fail when both socketMode and receiver are specified', async () => {
// Arrange
const fakeReceiver = new FakeReceiver();
const App = await importApp(); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match

// Act
try {
// eslint-disable-line @typescript-eslint/no-unused-expressions
new App({ token: '', signingSecret: '', socketMode: true, receiver: fakeReceiver });
assert.fail();
} catch (error) {
// Assert
assert.propertyVal(error, 'code', ErrorCode.AppInitializationError);
}
});
it('should initialize MemoryStore conversation store by default', async () => {
// Arrange
const fakeMemoryStore = sinon.fake();
Expand Down
3 changes: 3 additions & 0 deletions src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ export default class App {

// Check for required arguments of HTTPReceiver
if (receiver !== undefined) {
if (this.socketMode) {
throw new AppInitializationError('You cannot pass receiver when socketMode is set to true');
}
this.receiver = receiver;
} else if (this.socketMode) {
if (appToken === undefined) {
Expand Down

0 comments on commit f6c26af

Please sign in to comment.