This commit is contained in:
Philippe Torrel
2026-08-25 08:51:34 +02:00
parent 0803e08097
commit 18b5b4505e
9 changed files with 206 additions and 36 deletions

View File

@@ -30,7 +30,7 @@ describe('CategorySection', () => {
const imgs = screen.getAllByRole('img');
const links = screen.getAllByRole('link');
expect(imgs).toHaveLength(3); //.length()
expect(links).toHaveLength(3);
expect(imgs).toHaveLength(3); //.length() - from chai - TestFramework
expect(links).toHaveLength(3); // .lengthOf()
});
});

View File

@@ -19,7 +19,7 @@ describe('Footer', () => {
navItems.forEach((item) => {
const spanEl = screen.getByText(item.name);
const linkEl = spanEl.parentElement;
const linkEl = spanEl.parentNode;
expect(spanEl).toBeInTheDocument();
expect(linkEl).toHaveAttribute('href', item.href);
});

View File

@@ -65,11 +65,11 @@ describe('ImageGallery', () => {
const user = userEvent.setup();
expect(mainImage).toBeInTheDocument();
expect(mainImage).toHaveAttribute('src', product.images[0]);
await user.keyboard('{ArrowRight}');
expect(mainImage).toBeInTheDocument();
expect(mainImage).toHaveAttribute('src', product.images[1]);
});
@@ -79,6 +79,7 @@ describe('ImageGallery', () => {
const user = userEvent.setup();
expect(mainImage).toBeInTheDocument();
expect(mainImage).toHaveAttribute('src', product.images[0]);
await user.keyboard('{ArrowRight}');
@@ -86,7 +87,6 @@ describe('ImageGallery', () => {
await user.keyboard('{ArrowLeft}');
expect(mainImage).toBeInTheDocument();
expect(mainImage).toHaveAttribute('src', product.images[0]);
});
@@ -96,10 +96,11 @@ describe('ImageGallery', () => {
const user = userEvent.setup();
expect(mainImage).toBeInTheDocument();
expect(mainImage).toHaveAttribute('src', product.images[0]);
await user.keyboard('{ArrowLeft}');
expect(mainImage).toBeInTheDocument();
expect(mainImage).toHaveAttribute('src', product.images[product.images.length - 1]);
});
});