import { test, expect } from 'vitest';
import { render, screen } from '@testing-library/react';
import Details from './Details';
const SUMARY_TEXT = 'I can\'t sign in';
const CONTENT = '
hello
';
test('details renders correctly', () => {
render(
hello
);
const summaryElement = screen.getByText(SUMARY_TEXT);
const detailsElement = summaryElement.parentElement;
const textElement = summaryElement.nextElementSibling;
expect(detailsElement).toHaveClass('ds_details');
expect(detailsElement?.tagName).toEqual('DETAILS');
expect(summaryElement).toHaveClass('ds_details__summary');
expect(summaryElement?.tagName).toEqual('SUMMARY');
expect(textElement).toHaveClass('ds_details__text');
expect(textElement?.innerHTML).toEqual(CONTENT);
});
test('passing additional props', () => {
render(
hello
)
const summaryElement = screen.getByText(SUMARY_TEXT);
const detailsElement = summaryElement.parentElement;
expect(detailsElement?.dataset.test).toEqual('foo');
});
test('passing additional CSS classes', () => {
render(
hello
)
const summaryElement = screen.getByText(SUMARY_TEXT);
const detailsElement = summaryElement.parentElement;
expect(detailsElement).toHaveClass('foo', 'ds_details');
});