1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-09 10:22:46 +03:00
Files
matrix-js-sdk/spec/integ/matrix-client.spec.js
Kegan Dougal 3d90942e9b Appease jshint
2015-06-05 17:36:15 +01:00

53 lines
1.5 KiB
JavaScript

"use strict";
var sdk = require("../..");
var HttpBackend = require("../mock-request");
describe("MatrixClient", function() {
var baseUrl = "http://localhost.or.something";
var client, httpBackend;
beforeEach(function() {
httpBackend = new HttpBackend();
sdk.request(httpBackend.requestFn);
client = sdk.createClient(baseUrl);
});
afterEach(function() {
httpBackend.verifyNoOutstandingExpectation();
});
describe("startClient", function() {
var initialSync = {
end: "s_5_3",
presence: [],
rooms: []
};
var eventData = {
start: "s_5_3",
end: "e_6_7",
chunk: []
};
it("should start with /initialSync then move onto /events.", function() {
httpBackend.when("GET", "/initialSync").respond(200, initialSync);
httpBackend.when("GET", "/events").respond(200, eventData);
client.startClient(function(err, data, isLive) {});
httpBackend.flush();
});
it("should pass the 'end' token from /initialSync to the from= param "+
" of /events", function() {
httpBackend.when("GET", "/initialSync").respond(200, initialSync);
httpBackend.when("GET", "/events").check(function(req) {
expect(req.queryParams.from).toEqual(initialSync.end);
}).respond(200, eventData);
client.startClient(function(err, data, isLive) {});
httpBackend.flush();
});
});
});