URL encoding bugfix and add more tests.
This commit is contained in:
parent
a70765ed90
commit
4facbe02fb
|
@ -267,7 +267,7 @@ angular.module('matrixService', [])
|
|||
|
||||
// get room state for a specific room
|
||||
roomState: function(room_id) {
|
||||
var path = "/rooms/" + room_id + "/state";
|
||||
var path = "/rooms/" + encodeURIComponent(room_id) + "/state";
|
||||
return doRequest("GET", path);
|
||||
},
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue