Răsfoiți Sursa

Name anonymous function to fix failing test

JC Brand 5 ani în urmă
părinte
comite
4015eb2fd1
3 a modificat fișierele cu 12 adăugiri și 15 ștergeri
  1. 2 1
      spec/muc.js
  2. 9 7
      src/headless/converse-chatboxes.js
  3. 1 7
      src/headless/converse-muc.js

+ 2 - 1
spec/muc.js

@@ -5064,7 +5064,8 @@
                     expect(notifications.length).toBe(1);
                     expect(notifications[0].textContent.trim()).toEqual('nomorenicks is typing');
 
-                    timeout_functions[1]();
+                    timeout_functions.filter(f => f.name === 'bound safeDestroy').pop()();
+
                     events = view.el.querySelectorAll('.chat-event');
                     expect(events.length).toBe(3);
                     expect(events[0].textContent.trim()).toEqual('some1 has entered the groupchat');

+ 9 - 7
src/headless/converse-chatboxes.js

@@ -107,13 +107,15 @@ converse.plugins.add('converse-chatboxes', {
                     this.on('change:put', this.uploadFile, this);
                 }
                 if (this.isEphemeral()) {
-                    window.setTimeout(() => {
-                        try {
-                            this.destroy()
-                        } catch (e) {
-                            _converse.log(e, Strophe.LogLevel.ERROR);
-                        }
-                    }, 10000);
+                    window.setTimeout(this.safeDestroy.bind(this), 10000);
+                }
+            },
+
+            safeDestroy () {
+                try {
+                    this.destroy()
+                } catch (e) {
+                    _converse.log(e, Strophe.LogLevel.ERROR);
                 }
             },
 

+ 1 - 7
src/headless/converse-muc.js

@@ -256,13 +256,7 @@ converse.plugins.add('converse-muc', {
                     this.on('change:put', this.uploadFile, this);
                 }
                 if (this.isEphemeral()) {
-                    window.setTimeout(() => {
-                        try {
-                            this.destroy()
-                        } catch (e) {
-                            _converse.log(e, Strophe.LogLevel.ERROR);
-                        }
-                    }, 10000);
+                    window.setTimeout(this.safeDestroy.bind(this), 10000);
                 } else {
                     this.setOccupant();
                     this.setVCard();