From 406b38698c456635de3e69e2491041292746437a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Jaenisch?= Date: Fri, 9 Feb 2024 11:29:03 +0100 Subject: [PATCH] chore: apply formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want to be a good citizen, don't we? Signed-off-by: André Jaenisch --- src/lib/components/atoms/Avatar.svelte | 26 +++++------- src/routes/profile/+page.svelte | 5 +-- tests/components/atoms/Avatar.test.ts | 56 +++++++++++++------------- vitest.config.ts | 9 ++--- 4 files changed, 42 insertions(+), 54 deletions(-) diff --git a/src/lib/components/atoms/Avatar.svelte b/src/lib/components/atoms/Avatar.svelte index b29ae58..9c4db2f 100644 --- a/src/lib/components/atoms/Avatar.svelte +++ b/src/lib/components/atoms/Avatar.svelte @@ -1,21 +1,15 @@ - + diff --git a/src/routes/profile/+page.svelte b/src/routes/profile/+page.svelte index 435fc8d..b6de84a 100644 --- a/src/routes/profile/+page.svelte +++ b/src/routes/profile/+page.svelte @@ -8,10 +8,7 @@
- +
diff --git a/tests/components/atoms/Avatar.test.ts b/tests/components/atoms/Avatar.test.ts index 8547d37..8846a33 100644 --- a/tests/components/atoms/Avatar.test.ts +++ b/tests/components/atoms/Avatar.test.ts @@ -1,7 +1,7 @@ -import '@testing-library/jest-dom' -import { render, screen } from '@testing-library/svelte' +import '@testing-library/jest-dom'; +import { render, screen } from '@testing-library/svelte'; -import Avatar from '../../../src/lib/components/atoms/Avatar.svelte' +import Avatar from '../../../src/lib/components/atoms/Avatar.svelte'; describe('Avatar.svelte', () => { it('should mount', () => { @@ -12,49 +12,49 @@ describe('Avatar.svelte', () => { const { container } = render(Avatar); // Assert - expect(container).toBeTruthy() - }) + expect(container).toBeTruthy(); + }); it('should pick up the passed image', () => { // Arrange - const avatar = 'https://example.com/avatar.png' + const avatar = 'https://example.com/avatar.png'; // Act - render(Avatar, { avatar }) - const figure = screen.getByTestId('avatar') - const image = figure.querySelector('img') + render(Avatar, { avatar }); + const figure = screen.getByTestId('avatar'); + const image = figure.querySelector('img'); // Assert - expect(figure).toBeInTheDocument() - expect(image).not.toBeNull() - expect(image).toHaveAttribute('src', avatar) - }) + expect(figure).toBeInTheDocument(); + expect(image).not.toBeNull(); + expect(image).toHaveAttribute('src', avatar); + }); it('should use an image with alt text', () => { // Arrange - const avatar = 'https://example.com/avatar.png' - const displayName = 'Jane Doe' + const avatar = 'https://example.com/avatar.png'; + const displayName = 'Jane Doe'; // Act - render(Avatar, { avatar, displayName }) - const figure = screen.getByTestId('avatar') + render(Avatar, { avatar, displayName }); + const figure = screen.getByTestId('avatar'); // Assert - expect(figure).toBeInTheDocument() - expect(screen.getByAltText(displayName)).toBeDefined() - }) + expect(figure).toBeInTheDocument(); + expect(screen.getByAltText(displayName)).toBeDefined(); + }); it('should use the initials as text', () => { // Arrange - const displayName = 'Jane Doe' - const initials = displayName.substring(0, 2).toUpperCase() + const displayName = 'Jane Doe'; + const initials = displayName.substring(0, 2).toUpperCase(); // Act - render(Avatar, { displayName }) - const figure = screen.getByTestId('avatar') + render(Avatar, { displayName }); + const figure = screen.getByTestId('avatar'); // Assert - expect(figure).toBeInTheDocument() - expect(screen.getByText(initials)).toBeDefined() - }) -}) + expect(figure).toBeInTheDocument(); + expect(screen.getByText(initials)).toBeDefined(); + }); +}); diff --git a/vitest.config.ts b/vitest.config.ts index c27f011..b06d7ae 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -4,12 +4,9 @@ import { defineConfig } from 'vitest/config'; export default defineConfig({ plugins: [svelte({ hot: !process.env.VITEST })], test: { - - coverage: { - include: [ - 'src/**/*.svelte' - ] - }, + coverage: { + include: ['src/**/*.svelte'] + }, include: ['tests/**/*.test.ts'], environment: 'jsdom', globals: true