f6c8343751
This is displaying the created time of the user's profile. Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>
76 lines
1.8 KiB
TypeScript
76 lines
1.8 KiB
TypeScript
import '@testing-library/jest-dom';
|
|
import { render, screen } from '@testing-library/svelte';
|
|
|
|
import Created from '../../../src/lib/components/atoms/Created.svelte';
|
|
|
|
describe('Created.svelte', () => {
|
|
it('should mount', () => {
|
|
// Arrange
|
|
// Nothing to prepare
|
|
|
|
// Act
|
|
const { container } = render(Created);
|
|
|
|
// Assert
|
|
expect(container).toBeTruthy();
|
|
});
|
|
|
|
describe('when no created_at is passed', () => {
|
|
describe('when no created_at_formatted is passed', () => {
|
|
it('should be empty', () => {
|
|
// Arrange
|
|
// Nothing to prepare
|
|
|
|
// Act
|
|
const { container } = render(Created);
|
|
|
|
// Assert
|
|
expect(container.textContent).toEqual('');
|
|
});
|
|
});
|
|
|
|
describe('when created_at_formatted is passed', () => {
|
|
it('should be empty', () => {
|
|
// Arrange
|
|
const created_at_formatted = '2024-02-11';
|
|
|
|
// Act
|
|
const { container } = render(Created, { created_at_formatted });
|
|
|
|
// Assert
|
|
expect(container.textContent).toEqual('');
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('when created_at is passed', () => {
|
|
describe('when no created_at_formatted is passed', () => {
|
|
it('should be empty', () => {
|
|
// Arrange
|
|
const created_at = new Date();
|
|
|
|
// Act
|
|
const { container } = render(Created, { created_at });
|
|
|
|
// Assert
|
|
expect(container.textContent).toEqual('');
|
|
});
|
|
});
|
|
|
|
describe('when created_at_formatted is passed', () => {
|
|
it('should be empty', () => {
|
|
// Arrange
|
|
const created_at = new Date().toISOString();
|
|
const created_at_formatted = created_at.toString();
|
|
|
|
// Act
|
|
const { container } = render(Created, { created_at, created_at_formatted });
|
|
|
|
// Assert
|
|
expect(container.textContent).not.toEqual('');
|
|
expect(screen.getByText(created_at_formatted)).toBeDefined();
|
|
expect(screen.getByText(created_at_formatted)).toHaveAttribute('datetime', created_at);
|
|
});
|
|
});
|
|
});
|
|
});
|