summary refs log tree commit diff
path: root/syweb/webclient/test
diff options
context:
space:
mode:
Diffstat (limited to 'syweb/webclient/test')
-rw-r--r--syweb/webclient/test/unit/matrix-service.spec.js46
1 files changed, 40 insertions, 6 deletions
diff --git a/syweb/webclient/test/unit/matrix-service.spec.js b/syweb/webclient/test/unit/matrix-service.spec.js
index 3c5163e478..29d2ca7be7 100644
--- a/syweb/webclient/test/unit/matrix-service.spec.js
+++ b/syweb/webclient/test/unit/matrix-service.spec.js
@@ -1,5 +1,5 @@
 describe('MatrixService', function() {
-    var scope, httpBackend, createController;
+    var scope, httpBackend;
     var BASE = "http://example.com";
     var PREFIX = "/_matrix/client/api/v1";
     var URL = BASE + PREFIX;
@@ -7,7 +7,7 @@ describe('MatrixService', function() {
     
     beforeEach(module('matrixService'));
 
-    beforeEach(inject(function($rootScope, $httpBackend, $controller) {
+    beforeEach(inject(function($rootScope, $httpBackend) {
         httpBackend = $httpBackend;
         scope = $rootScope;
     }));
@@ -17,6 +17,40 @@ describe('MatrixService', function() {
         httpBackend.verifyNoOutstandingRequest();
     });
 
+    it('should be able to POST /createRoom with an alias', inject(function(matrixService) {
+        matrixService.setConfig({
+            access_token: "foobar",
+            homeserver: "http://example.com"
+        });
+        var alias = "flibble";
+        matrixService.create(alias).then(function(response) {
+            expect(response.data).toEqual({});
+        });
+
+        httpBackend.expectPOST(URL + "/createRoom?access_token=foobar",
+            {
+                room_alias_name: alias
+            })
+            .respond({});
+        httpBackend.flush();
+    }));
+
+    it('should be able to GET /initialSync', inject(function(matrixService) {
+        matrixService.setConfig({
+            access_token: "foobar",
+            homeserver: "http://example.com"
+        });
+        var limit = 15;
+        matrixService.initialSync(limit).then(function(response) {
+            expect(response.data).toEqual([]);
+        });
+
+        httpBackend.expectGET(
+            URL + "/initialSync?access_token=foobar&limit=15")
+            .respond([]);
+        httpBackend.flush();
+    }));
+    
     it('should be able to GET /rooms/$roomid/state', inject(function(matrixService) {
         matrixService.setConfig({
             access_token: "foobar",
@@ -26,8 +60,8 @@ describe('MatrixService', function() {
             expect(response.data).toEqual([]);
         });
 
-        httpBackend.expect('GET',
-            URL + "/rooms/" + roomId + "/state?access_token=foobar")
+        httpBackend.expectGET(
+            URL + "/rooms/" + encodeURIComponent(roomId) + "/state?access_token=foobar")
             .respond([]);
         httpBackend.flush();
     }));
@@ -41,7 +75,7 @@ describe('MatrixService', function() {
             expect(response.data).toEqual({});
         });
 
-        httpBackend.expect('POST',
+        httpBackend.expectPOST(
             URL + "/join/" + encodeURIComponent(roomId) + "?access_token=foobar")
             .respond({});
         httpBackend.flush();
@@ -56,7 +90,7 @@ describe('MatrixService', function() {
             expect(response.data).toEqual({});
         });
 
-        httpBackend.expect('POST',
+        httpBackend.expectPOST(
             URL + "/rooms/" + encodeURIComponent(roomId) + "/join?access_token=foobar")
             .respond({});
         httpBackend.flush();