import {test} from 'node:test';
import assert from 'node:assert/strict';
import {render, screen} from '@testing-library/react';
import Gallery, {Profile} from './main.jsx';
test('Lin Lanying is 80 pixels wide, as Gallery passes', () => {
render(<Gallery />);
const width = screen.getByRole('img', {name: 'Lin Lanying'}).getAttribute('width');
assert.equal(width, '80', 'the picture has width=' + JSON.stringify(width));
});
test('Aklilu Lemma gets the default size 60', () => {
render(<Gallery />);
const img = screen.getByRole('img', {name: 'Aklilu Lemma'});
assert.equal(img.getAttribute('width'), '60', 'the picture has width=' + JSON.stringify(img.getAttribute('width')));
assert.equal(img.getAttribute('height'), '60', 'the picture has height=' + JSON.stringify(img.getAttribute('height')));
});
test('Profile forwards any size and the picture', () => {
render(<Profile person={{ name: 'Ada', imageUrl: 'ada.jpg' }} size={40} />);
const img = screen.getByRole('img', {name: 'Ada'});
assert.equal(img.getAttribute('width'), '40', 'the picture has width=' + JSON.stringify(img.getAttribute('width')));
assert.equal(img.getAttribute('src'), 'ada.jpg', 'the picture has src=' + JSON.stringify(img.getAttribute('src')));
});
test('size={0} is passed on, not replaced by the default', () => {
render(<Profile person={{ name: 'Ada', imageUrl: 'ada.jpg' }} size={0} />);
const width = screen.getByRole('img', {name: 'Ada'}).getAttribute('width');
assert.equal(width, '0', 'the picture has width=' + JSON.stringify(width));
});