Browse Source

Add a test for serviceDiscovered event.

JC Brand 10 năm trước cách đây
mục cha
commit
f0df6df219
1 tập tin đã thay đổi với 25 bổ sung0 xóa
  1. 25 0
      spec/disco.js

+ 25 - 0
spec/disco.js

@@ -0,0 +1,25 @@
+(function (root, factory) {
+    define([
+        "jquery",
+        "mock",
+        "test_utils"
+        ], function ($, mock, test_utils) {
+            return factory($, mock, test_utils);
+        }
+    );
+} (this, function ($, mock, test_utils) {
+    "use strict";
+    var Strophe = converse_api.env.Strophe;
+
+    describe("Service Discovery", $.proxy(function (mock, test_utils) {
+
+        describe("Whenever converse.js discovers a new server feature", $.proxy(function (mock, test_utils) {
+           it("emits the serviceDiscovered event", function () {
+                spyOn(converse, 'emit');
+                converse.features.create({'var': Strophe.NS.MAM});
+                expect(converse.emit).toHaveBeenCalled();
+                expect(converse.emit.argsForCall[0][1].get('var')).toBe(Strophe.NS.MAM);
+            });
+        }, converse, mock, test_utils));
+    }, converse, mock, test_utils));
+}));