diff --git a/src/lib/components/atoms/DisplayName.svelte b/src/lib/components/atoms/DisplayName.svelte new file mode 100644 index 0000000..7f344b4 --- /dev/null +++ b/src/lib/components/atoms/DisplayName.svelte @@ -0,0 +1,17 @@ + + +

+ Profile for + {@html displayName} +

+

({@html pronoun})

diff --git a/src/routes/profile/+page.svelte b/src/routes/profile/+page.svelte index 71c1b15..7ee499a 100644 --- a/src/routes/profile/+page.svelte +++ b/src/routes/profile/+page.svelte @@ -2,6 +2,7 @@ import Avatar from '$lib/components/atoms/Avatar.svelte'; import BlockOrReport from '$lib/components/atoms/BlockOrReport.svelte'; import Created from '$lib/components/atoms/Created.svelte'; + import DisplayName from '$lib/components/atoms/DisplayName.svelte'; /** @type {import('./$types').PageData} */ export let data; @@ -26,11 +27,7 @@
-

- Profile for - {@html data.user.display_name} -

-

(she/her)

+
{@html data.user.username}@{@html data.user.instance} diff --git a/tests/components/atoms/DisplayName.test.ts b/tests/components/atoms/DisplayName.test.ts new file mode 100644 index 0000000..10cf548 --- /dev/null +++ b/tests/components/atoms/DisplayName.test.ts @@ -0,0 +1,20 @@ +import '@testing-library/jest-dom'; +import { render, screen } from '@testing-library/svelte'; + +import DisplayName from '../../../src/lib/components/atoms/DisplayName.svelte'; + +describe('DisplayName.svelte', () => { + it('should mount', () => { + // Arrange + const displayName = 'Jane Doe'; + const pronoun = 'she/her'; + + // Act + render(DisplayName, { displayName, pronoun }); + + // Assert + expect(screen.getByText(displayName)).toBeInTheDocument(); + // Turn into regular expression to respect round brackets + expect(screen.getByText(new RegExp(pronoun))).toBeInTheDocument(); + }); +});