Skip to content

Commit ae608d5

Browse files
committed
add tests to AvatarWithDetails
Signed-off-by: Timo K <[email protected]>
1 parent 9622a74 commit ae608d5

File tree

5 files changed

+54
-11
lines changed

5 files changed

+54
-11
lines changed
9.51 KB
Loading

src/shared-components/avatar/AvatarWithDetails/AvatarWithDetails.module.css

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,16 @@
99
display: flex;
1010
align-items: center;
1111

12-
border-radius: var(--cpd-space-3x);
12+
border-radius: 12px;
1313
background-color: var(--cpd-color-gray-200);
1414
padding: var(--cpd-space-2x);
15-
16-
div {
17-
margin-left: var(--cpd-space-2x);
18-
display: flex;
19-
flex-direction: column;
20-
}
15+
gap: var(--cpd-space-2x);
2116

2217
.room {
2318
display: inline-block;
2419

2520
font-weight: var(--cpd-font-weight-semibold);
2621
font-size: var(--cpd-font-size-body-md);
27-
line-height: var(--cpd-font-size-heading-md);
2822

2923
overflow: hidden;
3024
text-overflow: ellipsis;
@@ -33,6 +27,5 @@
3327

3428
.details {
3529
font-size: var(--cpd-font-size-body-sm);
36-
line-height: var(--cpd-font-size-body-md);
3730
}
3831
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Copyright 2025 New Vector Ltd.
3+
4+
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
5+
Please see LICENSE files in the repository root for full details.
6+
*/
7+
8+
import { composeStories } from "@storybook/react-vite";
9+
import { render } from "jest-matrix-react";
10+
import React from "react";
11+
12+
import * as stories from "./AvatarWithDetails.stories.tsx";
13+
14+
const { Default } = composeStories(stories);
15+
16+
describe("AvatarWithDetails", () => {
17+
it("renders a textual event", () => {
18+
const { container } = render(<Default />);
19+
expect(container).toMatchSnapshot();
20+
});
21+
});

src/shared-components/avatar/AvatarWithDetails/AvatarWithDetails.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import React from "react";
1010
import classNames from "classnames";
1111

1212
import styles from "./AvatarWithDetails.module.css";
13+
import { Flex } from "../../utils/Flex";
1314

1415
export type AvatarWithDetailsProps<C extends ElementType> = {
1516
/**
@@ -48,10 +49,10 @@ export function AvatarWithDetails<C extends React.ElementType = "div">({
4849
return (
4950
<Component className={classNames(styles.avatarWithDetails, className)} {...props}>
5051
{avatar}
51-
<div>
52+
<Flex direction="column">
5253
<span className={styles.room}>{roomName}</span>
5354
<span className={styles.details}>{details}</span>
54-
</div>
55+
</Flex>
5556
</Component>
5657
);
5758
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`AvatarWithDetails renders a textual event 1`] = `
4+
<div>
5+
<div
6+
class="avatarWithDetails"
7+
>
8+
<div
9+
style="width: 40px; height: 40px; background-color: rgb(136, 136, 136); border-radius: 50%;"
10+
/>
11+
<div
12+
class="flex"
13+
style="--mx-flex-display: flex; --mx-flex-direction: column; --mx-flex-align: start; --mx-flex-justify: start; --mx-flex-gap: 0; --mx-flex-wrap: nowrap;"
14+
>
15+
<span
16+
class="room"
17+
>
18+
Room Name
19+
</span>
20+
<span
21+
class="details"
22+
>
23+
Details about the avatar go here
24+
</span>
25+
</div>
26+
</div>
27+
</div>
28+
`;

0 commit comments

Comments
 (0)