Serach codeIdAttr in first message event

This commit is contained in:
Simon Warta 2020-02-05 09:10:17 +01:00
parent 5ac758c6ba
commit 6083c3f7ea

View File

@ -193,7 +193,9 @@ describe("RestClient", () => {
// console.log("Raw log:", result.raw_log);
expect(result.code).toBeFalsy();
const [firstLog] = parseSuccess(result.raw_log);
const codeIdAttr = firstLog.events[0].attributes.find(attr => attr.key === "code_id");
const codeIdAttr = firstLog.events
.find(event => event.type === "message")
?.attributes.find(attr => attr.key === "code_id");
if (!codeIdAttr) throw new Error("Could not find code_id attribute");
codeId = Number.parseInt(codeIdAttr.value, 10);
expect(codeId).toBeGreaterThanOrEqual(1);