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 all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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 @@ -298,6 +298,9 @@ export default class App {

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