diff options
author | Kegan Dougal <kegan@matrix.org> | 2014-11-04 17:19:49 +0000 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2014-11-04 17:19:49 +0000 |
commit | a70765ed90196a418023d080dd6ba313c6305633 (patch) | |
tree | 836fd5562a8705e6d0e7db4d8d96b5fd6184611c /syweb/webclient/test/unit/matrix-service.spec.js | |
parent | SYN-112: Get pynacl from github instead of PyPI (diff) | |
download | synapse-a70765ed90196a418023d080dd6ba313c6305633.tar.xz |
Add matrix-service unit tests. Update angular-mocks.
Diffstat (limited to 'syweb/webclient/test/unit/matrix-service.spec.js')
-rw-r--r-- | syweb/webclient/test/unit/matrix-service.spec.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/syweb/webclient/test/unit/matrix-service.spec.js b/syweb/webclient/test/unit/matrix-service.spec.js new file mode 100644 index 0000000000..3c5163e478 --- /dev/null +++ b/syweb/webclient/test/unit/matrix-service.spec.js @@ -0,0 +1,64 @@ +describe('MatrixService', function() { + var scope, httpBackend, createController; + var BASE = "http://example.com"; + var PREFIX = "/_matrix/client/api/v1"; + var URL = BASE + PREFIX; + var roomId = "!wejigf387t34:matrix.org"; + + beforeEach(module('matrixService')); + + beforeEach(inject(function($rootScope, $httpBackend, $controller) { + httpBackend = $httpBackend; + scope = $rootScope; + })); + + afterEach(function() { + httpBackend.verifyNoOutstandingExpectation(); + httpBackend.verifyNoOutstandingRequest(); + }); + + it('should be able to GET /rooms/$roomid/state', inject(function(matrixService) { + matrixService.setConfig({ + access_token: "foobar", + homeserver: "http://example.com" + }); + matrixService.roomState(roomId).then(function(response) { + expect(response.data).toEqual([]); + }); + + httpBackend.expect('GET', + URL + "/rooms/" + roomId + "/state?access_token=foobar") + .respond([]); + httpBackend.flush(); + })); + + it('should be able to POST /join', inject(function(matrixService) { + matrixService.setConfig({ + access_token: "foobar", + homeserver: "http://example.com" + }); + matrixService.joinAlias(roomId).then(function(response) { + expect(response.data).toEqual({}); + }); + + httpBackend.expect('POST', + URL + "/join/" + encodeURIComponent(roomId) + "?access_token=foobar") + .respond({}); + httpBackend.flush(); + })); + + it('should be able to POST /rooms/$roomid/join', inject(function(matrixService) { + matrixService.setConfig({ + access_token: "foobar", + homeserver: "http://example.com" + }); + matrixService.join(roomId).then(function(response) { + expect(response.data).toEqual({}); + }); + + httpBackend.expect('POST', + URL + "/rooms/" + encodeURIComponent(roomId) + "/join?access_token=foobar") + .respond({}); + httpBackend.flush(); + })); +}); |