summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--syweb/webclient/test/unit/matrix-service.spec.js57
1 files changed, 55 insertions, 2 deletions
diff --git a/syweb/webclient/test/unit/matrix-service.spec.js b/syweb/webclient/test/unit/matrix-service.spec.js
index ed290f2ff3..2ca9a24323 100644
--- a/syweb/webclient/test/unit/matrix-service.spec.js
+++ b/syweb/webclient/test/unit/matrix-service.spec.js
@@ -231,14 +231,14 @@ describe('MatrixService', function() {
         httpBackend.flush();
     }));
     
-    xit('should be able to send generic state events without a state key', inject(
+    it('should be able to send generic state events without a state key', inject(
     function(matrixService) {
         matrixService.setConfig({
             access_token: "foobar",
             homeserver: "http://example.com"
         });
         var roomId = "!fh38hfwfwef:example.com";
-        var eventType = "com.example.events.test:special@characters";
+        var eventType = "com.example.events.test";
         var content = {
             testing: "1 2 3"
         };
@@ -255,6 +255,8 @@ describe('MatrixService', function() {
         httpBackend.flush();
     }));
     
+    // TODO: Skipped since the webclient is purposefully broken so as not to
+    // 500 matrix.org
     xit('should be able to send generic state events with a state key', inject(
     function(matrixService) {
         matrixService.setConfig({
@@ -280,4 +282,55 @@ describe('MatrixService', function() {
             .respond({});
         httpBackend.flush();
     }));
+    
+    it('should be able to PUT generic events ', inject(
+    function(matrixService) {
+        matrixService.setConfig({
+            access_token: "foobar",
+            homeserver: "http://example.com"
+        });
+        var roomId = "!fh38hfwfwef:example.com";
+        var eventType = "com.example.events.test";
+        var txnId = "42";
+        var content = {
+            testing: "1 2 3"
+        };
+        matrixService.sendEvent(roomId, eventType, txnId, content).then(
+        function(response) {
+            expect(response.data).toEqual({});
+        });
+
+        httpBackend.expectPUT(
+            URL + "/rooms/" + encodeURIComponent(roomId) + "/send/" + 
+            encodeURIComponent(eventType) + "/" + encodeURIComponent(txnId)+
+            "?access_token=foobar",
+            content)
+            .respond({});
+        httpBackend.flush();
+    }));
+    
+    it('should be able to PUT text messages ', inject(
+    function(matrixService) {
+        matrixService.setConfig({
+            access_token: "foobar",
+            homeserver: "http://example.com"
+        });
+        var roomId = "!fh38hfwfwef:example.com";
+        var body = "ABC 123";
+        matrixService.sendTextMessage(roomId, body).then(
+        function(response) {
+            expect(response.data).toEqual({});
+        });
+
+        httpBackend.expectPUT(
+            new RegExp(URL + "/rooms/" + encodeURIComponent(roomId) + 
+            "/send/m.room.message/(.*)" +
+            "?access_token=foobar"),
+            {
+                body: body,
+                msgtype: "m.text"
+            })
+            .respond({});
+        httpBackend.flush();
+    }));
 });