Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Stablize test
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Sep 10, 2024
1 parent 2a14aee commit c43048d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/components/views/right_panel/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1710,7 +1710,6 @@ export const UserInfoHeader: React.FC<{
withDisplayName: true,
});
const displayName = (member as RoomMember).rawDisplayName;
console.log("booop", timezoneInfo);
return (
<React.Fragment>
<div className="mx_UserInfo_avatar">
Expand Down Expand Up @@ -1738,13 +1737,15 @@ export const UserInfoHeader: React.FC<{
</Flex>
</Heading>
{presenceLabel}
{timezoneInfo && <Tooltip label={timezoneInfo?.timezone ?? ""}>
<span className="mx_UserInfo_timezone">
<Text size="sm" weight="regular">
{timezoneInfo?.friendly ?? ""}
</Text>
</span>
</Tooltip>}
{timezoneInfo && (
<Tooltip label={timezoneInfo?.timezone ?? ""}>
<span className="mx_UserInfo_timezone">
<Text size="sm" weight="regular">
{timezoneInfo?.friendly ?? ""}
</Text>
</span>
</Tooltip>
)}
<Text size="sm" weight="semibold" className="mx_UserInfo_profile_mxid">
<CopyableText getTextToCopy={() => userIdentifier} border={false}>
{userIdentifier}
Expand Down
7 changes: 6 additions & 1 deletion test/components/views/right_panel/UserInfo-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ let mockRoom: Mocked<Room>;
let mockSpace: Mocked<Room>;
let mockClient: Mocked<MatrixClient>;
let mockCrypto: Mocked<CryptoApi>;
const origDate = global.Date.prototype.toLocaleString;

beforeEach(() => {
mockRoom = mocked({
Expand Down Expand Up @@ -240,10 +241,14 @@ describe("<UserInfo />", () => {
});

it("renders user timezone if set", async () => {
// For timezone, force a consistent locale.
jest.spyOn(global.Date.prototype, "toLocaleString").mockImplementation(function (_locale, opts) {
return origDate.call(this, "en-US", opts); // eslint-disable-line @typescript-eslint/no-invalid-this

Check failure on line 246 in test/components/views/right_panel/UserInfo-test.tsx

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

'this' implicitly has type 'any' because it does not have a type annotation.
});
mockClient.doesServerSupportExtendedProfiles.mockResolvedValue(true);
mockClient.getExtendedProfileProperty.mockResolvedValue("Europe/London");
renderComponent();
await expect(screen.findByText(/\d\d:\d\d (am|pm)/)).resolves.toBeInTheDocument();
await expect(screen.findByText(/\d\d:\d\d (AM|PM)/)).resolves.toBeInTheDocument();
});

it("renders encryption info panel without pending verification", () => {
Expand Down

0 comments on commit c43048d

Please sign in to comment.