Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1068 Throw an error if both socketMode: boolean and receiver: Receiver arguments in App constructor #1077

Merged
merged 4 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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');
seratch marked this conversation as resolved.
Show resolved Hide resolved
}
this.receiver = receiver;
} else if (this.socketMode) {
if (appToken === undefined) {
Expand Down