Format code

This commit is contained in:
Robin
2023-10-11 10:42:04 -04:00
parent b28e465122
commit 614bc82402
112 changed files with 628 additions and 602 deletions

View File

@@ -23,13 +23,13 @@ test("Toast renders", () => {
render(
<Toast open={false} onDismiss={() => {}}>
Hello world!
</Toast>
</Toast>,
);
expect(screen.queryByRole("dialog")).toBe(null);
render(
<Toast open={true} onDismiss={() => {}}>
Hello world!
</Toast>
</Toast>,
);
expect(screen.getByRole("dialog")).toMatchSnapshot();
});
@@ -39,7 +39,7 @@ test("Toast dismisses when clicked", async () => {
render(
<Toast open={true} onDismiss={onDismiss}>
Hello world!
</Toast>
</Toast>,
);
await userEvent.click(screen.getByRole("dialog"));
expect(onDismiss).toHaveBeenCalled();
@@ -51,7 +51,7 @@ test("Toast dismisses itself after the specified timeout", async () => {
render(
<Toast open={true} onDismiss={onDismiss} autoDismiss={2000}>
Hello world!
</Toast>
</Toast>,
);
jest.advanceTimersByTime(2000);
expect(onDismiss).toHaveBeenCalled();

View File

@@ -34,28 +34,28 @@ describe("UrlParams", () => {
describe("handles URL with /room/", () => {
it("and nothing else", () => {
expect(
getRoomIdentifierFromUrl(`/room/${ROOM_NAME}`, "", "").roomAlias
getRoomIdentifierFromUrl(`/room/${ROOM_NAME}`, "", "").roomAlias,
).toBe(`#${ROOM_NAME}:${HOMESERVER}`);
});
it("and #", () => {
expect(
getRoomIdentifierFromUrl("", `${ORIGIN}/room/`, `#${ROOM_NAME}`)
.roomAlias
.roomAlias,
).toBe(`#${ROOM_NAME}:${HOMESERVER}`);
});
it("and # and server part", () => {
expect(
getRoomIdentifierFromUrl("", `/room/`, `#${ROOM_NAME}:${HOMESERVER}`)
.roomAlias
.roomAlias,
).toBe(`#${ROOM_NAME}:${HOMESERVER}`);
});
it("and server part", () => {
expect(
getRoomIdentifierFromUrl(`/room/${ROOM_NAME}:${HOMESERVER}`, "", "")
.roomAlias
.roomAlias,
).toBe(`#${ROOM_NAME}:${HOMESERVER}`);
});
});
@@ -63,27 +63,27 @@ describe("UrlParams", () => {
describe("handles URL without /room/", () => {
it("and nothing else", () => {
expect(getRoomIdentifierFromUrl(`/${ROOM_NAME}`, "", "").roomAlias).toBe(
`#${ROOM_NAME}:${HOMESERVER}`
`#${ROOM_NAME}:${HOMESERVER}`,
);
});
it("and with #", () => {
expect(getRoomIdentifierFromUrl("", "", `#${ROOM_NAME}`).roomAlias).toBe(
`#${ROOM_NAME}:${HOMESERVER}`
`#${ROOM_NAME}:${HOMESERVER}`,
);
});
it("and with # and server part", () => {
expect(
getRoomIdentifierFromUrl("", "", `#${ROOM_NAME}:${HOMESERVER}`)
.roomAlias
.roomAlias,
).toBe(`#${ROOM_NAME}:${HOMESERVER}`);
});
it("and with server part", () => {
expect(
getRoomIdentifierFromUrl(`/${ROOM_NAME}:${HOMESERVER}`, "", "")
.roomAlias
.roomAlias,
).toBe(`#${ROOM_NAME}:${HOMESERVER}`);
});
});
@@ -91,7 +91,7 @@ describe("UrlParams", () => {
describe("handles search params", () => {
it("(roomId)", () => {
expect(
getRoomIdentifierFromUrl("", `?roomId=${ROOM_ID}`, "").roomId
getRoomIdentifierFromUrl("", `?roomId=${ROOM_ID}`, "").roomId,
).toBe(ROOM_ID);
});
});
@@ -99,7 +99,7 @@ describe("UrlParams", () => {
it("ignores room alias", () => {
expect(
getRoomIdentifierFromUrl("", `/room/${ROOM_NAME}:${HOMESERVER}`, "")
.roomAlias
.roomAlias,
).toBeFalsy();
});
});

View File

@@ -28,7 +28,7 @@ describe("CallList", () => {
<MemoryRouter>
<CallList client={{} as MatrixClient} rooms={rooms} />
</MemoryRouter>
</ClientProvider>
</ClientProvider>,
);
};

View File

@@ -20,7 +20,9 @@ test("initBeforeReact sets font family from URL param", () => {
window.location.hash = "#?font=DejaVu Sans";
Initializer.initBeforeReact();
expect(
getComputedStyle(document.documentElement).getPropertyValue("--font-family")
getComputedStyle(document.documentElement).getPropertyValue(
"--font-family",
),
).toBe('"DejaVu Sans"');
});
@@ -28,6 +30,6 @@ test("initBeforeReact sets font scale from URL param", () => {
window.location.hash = "#?fontScale=1.2";
Initializer.initBeforeReact();
expect(
getComputedStyle(document.documentElement).getPropertyValue("--font-scale")
getComputedStyle(document.documentElement).getPropertyValue("--font-scale"),
).toBe("1.2");
});

View File

@@ -120,7 +120,7 @@ describe("ObjectFlattener", () => {
statsReport.report.resolution,
flatObject,
"matrix.call.stats.connection.resolution.",
0
0,
);
expect(flatObject).toEqual({
"matrix.call.stats.connection.resolution.local.LOCAL_AUDIO_TRACK_ID.height":
@@ -146,7 +146,7 @@ describe("ObjectFlattener", () => {
statsReport.report.transport,
flatObject,
"matrix.call.stats.connection.transport.",
0
0,
);
expect(flatObject).toEqual({
"matrix.call.stats.connection.transport.0.ip":
@@ -177,8 +177,8 @@ describe("ObjectFlattener", () => {
expect(
ObjectFlattener.flattenReportObject(
"matrix.call.stats.connection",
statsReport.report
)
statsReport.report,
),
).toEqual({
"matrix.call.stats.connection.callId": "callId",
"matrix.call.stats.connection.opponentMemberId": "opponentMemberId",
@@ -259,8 +259,8 @@ describe("ObjectFlattener", () => {
expect(
ObjectFlattener.flattenReportObject(
"matrix.call.stats.bytesSend",
byteSentStatsReport
)
byteSentStatsReport,
),
).toEqual({
"matrix.call.stats.bytesSend.4aa92608-04c6-428e-8312-93e17602a959": 132093,
"matrix.call.stats.bytesSend.a08e4237-ee30-4015-a932-b676aec894b1": 913448,

View File

@@ -21,7 +21,7 @@ import { checkForParallelCalls } from "../../src/room/checkForParallelCalls";
import { withFakeTimers } from "../utils";
const withMockedPosthog = (
continuation: (posthog: Mocked<PosthogAnalytics>) => void
continuation: (posthog: Mocked<PosthogAnalytics>) => void,
) => {
const posthog = mocked({
trackEvent: jest.fn(),
@@ -37,7 +37,7 @@ const withMockedPosthog = (
};
const mockRoomState = (
groupCallMemberContents: Record<string, unknown>[]
groupCallMemberContents: Record<string, unknown>[],
): RoomState => {
const stateEvents = groupCallMemberContents.map((content) => ({
getContent: () => content,

View File

@@ -81,7 +81,7 @@ testFillGaps(
`
`,
`
`
`,
);
testFillGaps(
@@ -93,7 +93,7 @@ ef`,
`
ab
cd
ef`
ef`,
);
testFillGaps(
@@ -104,7 +104,7 @@ cde
f`,
`
cab
fde`
fde`,
);
testFillGaps(
@@ -117,7 +117,7 @@ mno`,
`
aebch
difgl
mjnok`
mjnok`,
);
testFillGaps(
@@ -130,7 +130,7 @@ ijkl`,
`
abcd
ehkf
glji`
glji`,
);
testFillGaps(
@@ -141,7 +141,7 @@ aa
bc`,
`
aa
cb`
cb`,
);
testFillGaps(
@@ -156,7 +156,7 @@ k`,
abce
dddf
dddj
kghi`
kghi`,
);
testFillGaps(
@@ -169,7 +169,7 @@ i`,
`
afbc
dddd
iegh`
iegh`,
);
testFillGaps(
@@ -183,7 +183,7 @@ ii`,
`
abcd
iigh
iief`
iief`,
);
testFillGaps(
@@ -198,7 +198,7 @@ hh
`
abcd
hhfg
hhie`
hhie`,
);
testFillGaps(
@@ -213,14 +213,14 @@ ghij`,
aadf
aaji
bcch
eccg`
eccg`,
);
function testCycleTileSize(
title: string,
tileId: string,
input: string,
output: string
output: string,
): void {
test(`cycleTileSize ${title}`, () => {
const grid = mkGrid(input);
@@ -240,7 +240,7 @@ ghi`,
acc
dcc
gbe
ifh`
ifh`,
);
testCycleTileSize(
@@ -253,7 +253,7 @@ efgh`,
acdh
bggg
fggg
e`
e`,
);
testCycleTileSize(
@@ -267,7 +267,7 @@ jk`,
`
abhc
djge
fik`
fik`,
);
testCycleTileSize(
@@ -287,7 +287,7 @@ dde
ddf
ccm
cch
lik`
lik`,
);
testCycleTileSize(
@@ -302,7 +302,7 @@ ddf`,
abb
cbb
dde
ddf`
ddf`,
);
test("cycleTileSize is its own inverse", () => {
@@ -337,18 +337,18 @@ function testAddItems(
title: string,
items: TileDescriptor<unknown>[],
input: string,
output: string
output: string,
): void {
test(`addItems ${title}`, () => {
expect(showGrid(addItems(items, mkGrid(input) as SparseGrid) as Grid)).toBe(
output
output,
);
});
}
testAddItems(
"appends 1×1 tiles",
["e", "f"].map((i) => ({ id: i } as unknown as TileDescriptor<unknown>)),
["e", "f"].map((i) => ({ id: i }) as unknown as TileDescriptor<unknown>),
`
aab
aac
@@ -356,7 +356,7 @@ d`,
`
aab
aac
def`
def`,
);
testAddItems(
@@ -368,7 +368,7 @@ def`,
`
abc
g
def`
def`,
);
testAddItems(
@@ -381,7 +381,7 @@ def`,
abc
ggf
gge
d`
d`,
);
function testMoveTile(
@@ -389,7 +389,7 @@ function testMoveTile(
from: number,
to: number,
input: string,
output: string
output: string,
): void {
test(`moveTile ${title}`, () => {
expect(showGrid(moveTile(mkGrid(input), from, to))).toBe(output);
@@ -403,7 +403,7 @@ testMoveTile(
`
abc`,
`
abc`
abc`,
);
testMoveTile(
@@ -413,7 +413,7 @@ testMoveTile(
`
abc`,
`
abc`
abc`,
);
testMoveTile(
@@ -427,7 +427,7 @@ cce`,
`
acc
bcc
d e`
d e`,
);
testMoveTile(
@@ -441,14 +441,14 @@ cce`,
`
abb
ccd
cce`
cce`,
);
function testResize(
title: string,
columns: number,
input: string,
output: string
output: string,
): void {
test(`resize ${title}`, () => {
expect(showGrid(resize(mkGrid(input), columns))).toBe(output);
@@ -471,7 +471,7 @@ bb
dd
dd
ch
eg`
eg`,
);
testResize(
@@ -489,5 +489,5 @@ eg`,
afcd
bbbg
bbbe
h`
h`,
);