Skip to content

Commit 2ddd1bb

Browse files
committed
Format with Prettier
1 parent 7235006 commit 2ddd1bb

File tree

1 file changed

+91
-85
lines changed

1 file changed

+91
-85
lines changed

test/ClientWidgetApi-test.ts

Lines changed: 91 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -507,109 +507,115 @@ describe("ClientWidgetApi", () => {
507507
});
508508

509509
it.each([
510-
{ hasDelay: true, hasParent: false },
510+
{ hasDelay: true, hasParent: false },
511511
{ hasDelay: false, hasParent: true },
512-
{ hasDelay: true, hasParent: true },
513-
])("sends delayed message events (hasDelay = $hasDelay, hasParent = $hasParent)", async ({ hasDelay, hasParent }) => {
514-
const roomId = "!room:example.org";
515-
const timeoutDelayId = "ft";
516-
517-
driver.sendDelayedEvent.mockResolvedValue({
518-
roomId,
519-
delayId: timeoutDelayId,
520-
});
512+
{ hasDelay: true, hasParent: true },
513+
])(
514+
"sends delayed message events (hasDelay = $hasDelay, hasParent = $hasParent)",
515+
async ({ hasDelay, hasParent }) => {
516+
const roomId = "!room:example.org";
517+
const timeoutDelayId = "ft";
518+
519+
driver.sendDelayedEvent.mockResolvedValue({
520+
roomId,
521+
delayId: timeoutDelayId,
522+
});
521523

522-
const event: ISendEventFromWidgetActionRequest = {
523-
api: WidgetApiDirection.FromWidget,
524-
widgetId: "test",
525-
requestId: "0",
526-
action: WidgetApiFromWidgetAction.SendEvent,
527-
data: {
528-
type: "m.room.message",
529-
content: {},
530-
room_id: roomId,
531-
...(hasDelay && { delay: 5000 }),
532-
...(hasParent && { parent_delay_id: "fp" }),
533-
},
534-
};
524+
const event: ISendEventFromWidgetActionRequest = {
525+
api: WidgetApiDirection.FromWidget,
526+
widgetId: "test",
527+
requestId: "0",
528+
action: WidgetApiFromWidgetAction.SendEvent,
529+
data: {
530+
type: "m.room.message",
531+
content: {},
532+
room_id: roomId,
533+
...(hasDelay && { delay: 5000 }),
534+
...(hasParent && { parent_delay_id: "fp" }),
535+
},
536+
};
535537

536-
await loadIframe([
537-
`org.matrix.msc2762.timeline:${event.data.room_id}`,
538-
`org.matrix.msc2762.send.event:${event.data.type}`,
539-
"org.matrix.msc4157.send.delayed_event",
540-
]);
538+
await loadIframe([
539+
`org.matrix.msc2762.timeline:${event.data.room_id}`,
540+
`org.matrix.msc2762.send.event:${event.data.type}`,
541+
"org.matrix.msc4157.send.delayed_event",
542+
]);
541543

542-
emitEvent(new CustomEvent("", { detail: event }));
544+
emitEvent(new CustomEvent("", { detail: event }));
543545

544-
await waitFor(() => {
545-
expect(transport.reply).toHaveBeenCalledWith(event, {
546-
room_id: roomId,
547-
delay_id: timeoutDelayId,
546+
await waitFor(() => {
547+
expect(transport.reply).toHaveBeenCalledWith(event, {
548+
room_id: roomId,
549+
delay_id: timeoutDelayId,
550+
});
548551
});
549-
});
550552

551-
expect(driver.sendDelayedEvent).toHaveBeenCalledWith(
552-
event.data.delay ?? null,
553-
event.data.parent_delay_id ?? null,
554-
event.data.type,
555-
event.data.content,
556-
null,
557-
roomId,
558-
);
559-
});
553+
expect(driver.sendDelayedEvent).toHaveBeenCalledWith(
554+
event.data.delay ?? null,
555+
event.data.parent_delay_id ?? null,
556+
event.data.type,
557+
event.data.content,
558+
null,
559+
roomId,
560+
);
561+
},
562+
);
560563

561564
it.each([
562565
{ hasDelay: true, hasParent: false },
563566
{ hasDelay: false, hasParent: true },
564567
{ hasDelay: true, hasParent: true },
565-
])("sends delayed state events (hasDelay = $hasDelay, hasParent = $hasParent)", async ({ hasDelay, hasParent }) => {
566-
const roomId = "!room:example.org";
567-
const timeoutDelayId = "ft";
568-
569-
driver.sendDelayedEvent.mockResolvedValue({
570-
roomId,
571-
delayId: timeoutDelayId,
572-
});
568+
])(
569+
"sends delayed state events (hasDelay = $hasDelay, hasParent = $hasParent)",
570+
async ({ hasDelay, hasParent }) => {
571+
const roomId = "!room:example.org";
572+
const timeoutDelayId = "ft";
573+
574+
driver.sendDelayedEvent.mockResolvedValue({
575+
roomId,
576+
delayId: timeoutDelayId,
577+
});
573578

574-
const event: ISendEventFromWidgetActionRequest = {
575-
api: WidgetApiDirection.FromWidget,
576-
widgetId: "test",
577-
requestId: "0",
578-
action: WidgetApiFromWidgetAction.SendEvent,
579-
data: {
580-
type: "m.room.topic",
581-
content: {},
582-
state_key: "",
583-
room_id: roomId,
584-
...(hasDelay && { delay: 5000 }),
585-
...(hasParent && { parent_delay_id: "fp" }),
586-
},
587-
};
579+
const event: ISendEventFromWidgetActionRequest = {
580+
api: WidgetApiDirection.FromWidget,
581+
widgetId: "test",
582+
requestId: "0",
583+
action: WidgetApiFromWidgetAction.SendEvent,
584+
data: {
585+
type: "m.room.topic",
586+
content: {},
587+
state_key: "",
588+
room_id: roomId,
589+
...(hasDelay && { delay: 5000 }),
590+
...(hasParent && { parent_delay_id: "fp" }),
591+
},
592+
};
588593

589-
await loadIframe([
590-
`org.matrix.msc2762.timeline:${event.data.room_id}`,
591-
`org.matrix.msc2762.send.state_event:${event.data.type}`,
592-
"org.matrix.msc4157.send.delayed_event",
593-
]);
594+
await loadIframe([
595+
`org.matrix.msc2762.timeline:${event.data.room_id}`,
596+
`org.matrix.msc2762.send.state_event:${event.data.type}`,
597+
"org.matrix.msc4157.send.delayed_event",
598+
]);
594599

595-
emitEvent(new CustomEvent("", { detail: event }));
600+
emitEvent(new CustomEvent("", { detail: event }));
596601

597-
await waitFor(() => {
598-
expect(transport.reply).toHaveBeenCalledWith(event, {
599-
room_id: roomId,
600-
delay_id: timeoutDelayId,
602+
await waitFor(() => {
603+
expect(transport.reply).toHaveBeenCalledWith(event, {
604+
room_id: roomId,
605+
delay_id: timeoutDelayId,
606+
});
601607
});
602-
});
603608

604-
expect(driver.sendDelayedEvent).toHaveBeenCalledWith(
605-
event.data.delay ?? null,
606-
event.data.parent_delay_id ?? null,
607-
event.data.type,
608-
event.data.content,
609-
"",
610-
roomId,
611-
);
612-
});
609+
expect(driver.sendDelayedEvent).toHaveBeenCalledWith(
610+
event.data.delay ?? null,
611+
event.data.parent_delay_id ?? null,
612+
event.data.type,
613+
event.data.content,
614+
"",
615+
roomId,
616+
);
617+
},
618+
);
613619

614620
it("should reject requests when the driver throws an exception", async () => {
615621
const roomId = "!room:example.org";

0 commit comments

Comments
 (0)