simple unit test for hsApi

This commit is contained in:
Bruno Windels 2020-04-22 20:47:31 +02:00
parent 277c8af628
commit 3f840d9d33

View File

@ -138,3 +138,27 @@ export class HomeServerApi {
return this._request("GET", `${this._homeserver}/_matrix/client/versions`, null, options); return this._request("GET", `${this._homeserver}/_matrix/client/versions`, null, options);
} }
} }
export function tests() {
function createRequestMock(result) {
return function() {
return {
abort() {},
response() {
return Promise.resolve(result);
}
}
}
}
return {
"superficial happy path for GET": async assert => {
const hsApi = new HomeServerApi({
request: createRequestMock({body: 42, status: 200}),
homeServer: "https://hs.tld"
});
const result = await hsApi._get("foo", null, null, null).response();
assert.strictEqual(result, 42);
}
}
}