runtime non-null assertion to coerce

This commit is contained in:
Kisaragi Marine 2024-06-21 04:30:28 +09:00
parent 997b588847
commit b99b7b5392
No known key found for this signature in database
GPG Key ID: C6631564CD2110E4

View File

@ -47,6 +47,7 @@ export const successfulApiCall = async <E extends keyof misskey.Endpoints, P ext
const res = await api(endpoint, parameters, user); const res = await api(endpoint, parameters, user);
const status = assertion.status ?? (res.body == null ? 204 : 200); const status = assertion.status ?? (res.body == null ? 204 : 200);
assert.strictEqual(res.status, status, inspect(res.body, { depth: 5, colors: true })); assert.strictEqual(res.status, status, inspect(res.body, { depth: 5, colors: true }));
assert.ok(res.body);
return res.body; return res.body;
}; };
@ -59,6 +60,7 @@ export const failedApiCall = async <T, E extends keyof misskey.Endpoints, P exte
const { status, code, id } = assertion; const { status, code, id } = assertion;
const res = await api(endpoint, parameters, user); const res = await api(endpoint, parameters, user);
assert.strictEqual(res.status, status, inspect(res.body)); assert.strictEqual(res.status, status, inspect(res.body));
assert.ok(res.body);
assert.strictEqual(res.body.error.code, code, inspect(res.body)); assert.strictEqual(res.body.error.code, code, inspect(res.body));
assert.strictEqual(res.body.error.id, id, inspect(res.body)); assert.strictEqual(res.body.error.id, id, inspect(res.body));
return res.body; return res.body;