import {test} from 'node:test';
import assert from 'node:assert/strict';
import {render, screen} from '@testing-library/react';
import TodoHeader from './main.jsx';
test("Die Überschrift lautet Gregorio Y. Zara's Todos", () => {
render(<TodoHeader />);
const heading = screen.getByRole('heading', {level: 1}).textContent;
assert.equal(heading, "Gregorio Y. Zara's Todos", 'die Überschrift lautet ' + JSON.stringify(heading));
});
test('Das Bild liest src und alt aus person', () => {
render(<TodoHeader />);
const img = screen.getByRole('img');
assert.equal(img.getAttribute('src'), 'gregorio-zara.jpg', 'das Bild hat src=' + JSON.stringify(img.getAttribute('src')));
assert.equal(img.getAttribute('alt'), 'Gregorio Y. Zara', 'das Bild hat alt=' + JSON.stringify(img.getAttribute('alt')));
});
test('Das Bild ist 90px breit und hoch, aus person.imageSize', () => {
render(<TodoHeader />);
const {width, height} = screen.getByRole('img').style;
assert.equal(width, '90px', 'das Bild hat die Breite ' + JSON.stringify(width));
assert.equal(height, '90px', 'das Bild hat die Höhe ' + JSON.stringify(height));
});
test('Der Header verwendet person.theme als Style', () => {
render(<TodoHeader />);
const {backgroundColor, color} = screen.getByRole('banner').style;
assert.equal(backgroundColor, 'black', 'der Header hat background-color ' + JSON.stringify(backgroundColor));
assert.equal(color, 'pink', 'der Header hat color ' + JSON.stringify(color));
});
test('React gibt keine Warnungen aus', () => {
const warnings = [];
const original = console.error;
console.error = (...args) => warnings.push(args.join(' '));
try {
render(<TodoHeader />);
} finally {
console.error = original;
}
assert.deepEqual(warnings, [], 'console.error beim Rendern');
});