mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
simple unit test for hsApi
This commit is contained in:
parent
277c8af628
commit
3f840d9d33
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user