This is an automated email from the ASF dual-hosted git repository.
jialiang pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 7409f510ec AMBARI-26098: Stomp test cases failed (#3797)
7409f510ec is described below
commit 7409f510ecc8587a846554224ae4173a7beef6c6
Author: zrain <[email protected]>
AuthorDate: Mon Jul 29 15:06:20 2024 +0800
AMBARI-26098: Stomp test cases failed (#3797)
AMBARI-26098: Stomp test cases failed (#3797)
---
ambari-web/app/utils/stomp_client.js | 2 +-
ambari-web/test/utils/stomp_client_test.js | 18 ++++++++++++++----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/ambari-web/app/utils/stomp_client.js
b/ambari-web/app/utils/stomp_client.js
index cb0af27770..989a7a3d8d 100644
--- a/ambari-web/app/utils/stomp_client.js
+++ b/ambari-web/app/utils/stomp_client.js
@@ -183,7 +183,7 @@ module.exports = Em.Object.extend({
disconnect: function () {
var client = this.get('client');
- if (client.ws.readyState === client.ws.OPEN) {
+ if (client && client.ws && (client.ws.readyState === client.ws.OPEN)) {
client.disconnect();
}
},
diff --git a/ambari-web/test/utils/stomp_client_test.js
b/ambari-web/test/utils/stomp_client_test.js
index f1fba23b39..45368fd7e7 100644
--- a/ambari-web/test/utils/stomp_client_test.js
+++ b/ambari-web/test/utils/stomp_client_test.js
@@ -167,11 +167,21 @@ describe('App.StompClient', function () {
});
describe('#disconnect', function() {
- var client = {
- disconnect: sinon.spy()
- };
+ it('disconnect should not be called when the connection is not open',
function() {
+ var client = {
+ disconnect: sinon.spy(),
+ ws: { readyState: -1, OPEN: 1 }
+ };
+ stomp.set('client', client);
+ stomp.disconnect();
+ expect(client.disconnect.calledOnce).to.be.false;
+ });
- it('disconnect should be called', function() {
+ it('disconnect should be called when the connection is opening',
function() {
+ var client = {
+ disconnect: sinon.spy(),
+ ws: { readyState: 1, OPEN: 1 }
+ };
stomp.set('client', client);
stomp.disconnect();
expect(client.disconnect.calledOnce).to.be.true;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]