Skip to content

Commit

Permalink
rtm-api: fix for #842, explicit disconnect while disconnected should …
Browse files Browse the repository at this point in the history
…transition back to disconnected. also add basic integration tests.
  • Loading branch information
filmaj committed Mar 28, 2024
1 parent ac507e0 commit 511ede7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/rtm-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"build": "npm run build:clean && tsc",
"build:clean": "shx rm -rf ./dist",
"lint": "eslint --fix --ext .ts src",
"test": "npm run lint && npm run build",
"test": "npm run lint && npm run build && npm run test:integration",
"test:integration": "mocha --config .mocharc.json test/integration.spec.js",
"ref-docs:model": "api-extractor run"
},
"dependencies": {
Expand All @@ -55,15 +56,23 @@
"@microsoft/api-extractor": "^7",
"@typescript-eslint/eslint-plugin": "^6",
"@typescript-eslint/parser": "^6",
"@types/chai": "^4",
"@types/mocha": "^10",
"@types/sinon": "^17",
"@types/ws": "^8",
"chai": "^4",
"eslint": "^8",
"eslint-config-airbnb-base": "^15",
"eslint-config-airbnb-typescript": "^17",
"eslint-plugin-import": "^2",
"eslint-plugin-import-newlines": "^1.3.4",
"eslint-plugin-jsdoc": "^48",
"eslint-plugin-node": "^11",
"mocha": "^10",
"shx": "^0.3.2",
"sinon": "^17",
"source-map-support": "^0.5.21",
"ts-node": "^10",
"typescript": "5.3.3"
}
}
1 change: 1 addition & 0 deletions packages/rtm-api/src/RTMClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class RTMClient extends EventEmitter {
/* eslint-disable @typescript-eslint/indent, newline-per-chained-call */
.initialState('disconnected')
.on('start').transitionTo('connecting')
.on('explicit disconnect').transitionTo('disconnected')
.onEnter(() => {
// each client should start out with the outgoing event queue paused
this.logger.debug('pausing outgoing event queue');
Expand Down
2 changes: 1 addition & 1 deletion packages/rtm-api/test/integration.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('Integration tests with a WebSocket server', () => {
});
await client.disconnect();
});
it.only('should not raise an exception if calling disconnect() when already disconnected', async () => {
it('should not raise an exception if calling disconnect() when already disconnected', async () => {
// https://github.com/slackapi/node-slack-sdk/issues/842
await client.disconnect();
});
Expand Down

0 comments on commit 511ede7

Please sign in to comment.