diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-11-05 12:32:28 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-11-05 12:32:28 +0000 |
commit | 0881a8ae6f6468af8345fc9e6e46bdb32dfb405b (patch) | |
tree | 0cd47e10af50681fa3ac025b5a8314c4014de212 /syweb/webclient/test/unit | |
parent | Fix url decoding bugs with /redact and /send APIs. (diff) | |
download | synapse-0881a8ae6f6468af8345fc9e6e46bdb32dfb405b.tar.xz |
Add more tests and a TODO.
Diffstat (limited to 'syweb/webclient/test/unit')
-rw-r--r-- | syweb/webclient/test/unit/matrix-service.spec.js | 57 |
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(); + })); }); |