chore: apply formatting
We want to be a good citizen, don't we? Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>
This commit is contained in:
parent
9c4c8f04f4
commit
406b38698c
4 changed files with 42 additions and 54 deletions
|
@ -1,21 +1,15 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Avatar } from '@skeletonlabs/skeleton';
|
import { Avatar } from '@skeletonlabs/skeleton';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL to Avatar image.
|
* URL to Avatar image.
|
||||||
*/
|
*/
|
||||||
export let avatar: string | undefined = '';
|
export let avatar: string | undefined = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name to derive initials from if no avatar is given.
|
* Name to derive initials from if no avatar is given.
|
||||||
*/
|
*/
|
||||||
export let displayName: string | undefined = '';
|
export let displayName: string | undefined = '';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Avatar
|
<Avatar src={avatar} alt={displayName} width="w-32" rounded="rounded-full" initials={displayName} />
|
||||||
src={avatar}
|
|
||||||
alt={displayName}
|
|
||||||
width="w-32"
|
|
||||||
rounded="rounded-full"
|
|
||||||
initials={displayName}
|
|
||||||
/>
|
|
||||||
|
|
|
@ -8,10 +8,7 @@
|
||||||
<section class="w-full mx-auto flex px-8 pt-8">
|
<section class="w-full mx-auto flex px-8 pt-8">
|
||||||
<!-- Profile header -->
|
<!-- Profile header -->
|
||||||
<div>
|
<div>
|
||||||
<Avatar
|
<Avatar avatar={data.user.avatar} displayName={data.user.display_name} />
|
||||||
avatar={data.user.avatar}
|
|
||||||
displayName={data.user.display_name}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Board -->
|
<!-- Board -->
|
||||||
<div class="flex flex-1 flex-col pl-8">
|
<div class="flex flex-1 flex-col pl-8">
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import '@testing-library/jest-dom'
|
import '@testing-library/jest-dom';
|
||||||
import { render, screen } from '@testing-library/svelte'
|
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', () => {
|
describe('Avatar.svelte', () => {
|
||||||
it('should mount', () => {
|
it('should mount', () => {
|
||||||
|
@ -12,49 +12,49 @@ describe('Avatar.svelte', () => {
|
||||||
const { container } = render(Avatar);
|
const { container } = render(Avatar);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(container).toBeTruthy()
|
expect(container).toBeTruthy();
|
||||||
})
|
});
|
||||||
|
|
||||||
it('should pick up the passed image', () => {
|
it('should pick up the passed image', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const avatar = 'https://example.com/avatar.png'
|
const avatar = 'https://example.com/avatar.png';
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
render(Avatar, { avatar })
|
render(Avatar, { avatar });
|
||||||
const figure = screen.getByTestId('avatar')
|
const figure = screen.getByTestId('avatar');
|
||||||
const image = figure.querySelector('img')
|
const image = figure.querySelector('img');
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(figure).toBeInTheDocument()
|
expect(figure).toBeInTheDocument();
|
||||||
expect(image).not.toBeNull()
|
expect(image).not.toBeNull();
|
||||||
expect(image).toHaveAttribute('src', avatar)
|
expect(image).toHaveAttribute('src', avatar);
|
||||||
})
|
});
|
||||||
|
|
||||||
it('should use an image with alt text', () => {
|
it('should use an image with alt text', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const avatar = 'https://example.com/avatar.png'
|
const avatar = 'https://example.com/avatar.png';
|
||||||
const displayName = 'Jane Doe'
|
const displayName = 'Jane Doe';
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
render(Avatar, { avatar, displayName })
|
render(Avatar, { avatar, displayName });
|
||||||
const figure = screen.getByTestId('avatar')
|
const figure = screen.getByTestId('avatar');
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(figure).toBeInTheDocument()
|
expect(figure).toBeInTheDocument();
|
||||||
expect(screen.getByAltText(displayName)).toBeDefined()
|
expect(screen.getByAltText(displayName)).toBeDefined();
|
||||||
})
|
});
|
||||||
|
|
||||||
it('should use the initials as text', () => {
|
it('should use the initials as text', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const displayName = 'Jane Doe'
|
const displayName = 'Jane Doe';
|
||||||
const initials = displayName.substring(0, 2).toUpperCase()
|
const initials = displayName.substring(0, 2).toUpperCase();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
render(Avatar, { displayName })
|
render(Avatar, { displayName });
|
||||||
const figure = screen.getByTestId('avatar')
|
const figure = screen.getByTestId('avatar');
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(figure).toBeInTheDocument()
|
expect(figure).toBeInTheDocument();
|
||||||
expect(screen.getByText(initials)).toBeDefined()
|
expect(screen.getByText(initials)).toBeDefined();
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
|
@ -4,12 +4,9 @@ import { defineConfig } from 'vitest/config';
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [svelte({ hot: !process.env.VITEST })],
|
plugins: [svelte({ hot: !process.env.VITEST })],
|
||||||
test: {
|
test: {
|
||||||
|
coverage: {
|
||||||
coverage: {
|
include: ['src/**/*.svelte']
|
||||||
include: [
|
},
|
||||||
'src/**/*.svelte'
|
|
||||||
]
|
|
||||||
},
|
|
||||||
include: ['tests/**/*.test.ts'],
|
include: ['tests/**/*.test.ts'],
|
||||||
environment: 'jsdom',
|
environment: 'jsdom',
|
||||||
globals: true
|
globals: true
|
||||||
|
|
Loading…
Reference in a new issue