Skip to content

Commit

Permalink
fix: populartitle test
Browse files Browse the repository at this point in the history
Implement "Most Popular" Section on Landing Page #27
  • Loading branch information
niyibi250 committed Jun 27, 2024
1 parent f31c73b commit ffc18fd
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 54 deletions.
Empty file removed src/__test__/MostSelling.test.tsx
Empty file.
24 changes: 24 additions & 0 deletions src/__test__/PopularBanner.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { render, screen } from '@testing-library/react';
import { describe, it, expect } from 'vitest'; // Assuming 'vitest' is used for assertions
import BannerAD from '@/components/Popular-section/BannerAD'; // Adjust path as needed
import ADImage from '@/assets/image/Rectangle 901.svg'; // Adjust path as needed

describe('BannerAD Component', () => {
it('renders BannerAD component correctly', () => {
render(<BannerAD />);

const headline = screen.getByText(
'In store or online your health & safety is our priority'
);
expect(headline).toBeInTheDocument();

const description = screen.getByText(
'The only E-commerce that makes your life easier, makes you enjoy life and makes it bette'
);
expect(description).toBeInTheDocument();

const adImage = screen.getByAltText('AD image');
expect(adImage).toBeInTheDocument();
expect(adImage.getAttribute('src')).toBe(ADImage); // Ensure correct image source
});
});
File renamed without changes.
33 changes: 33 additions & 0 deletions src/__test__/PopularTitle.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { render, screen } from '@testing-library/react';
import { describe, it, expect } from 'vitest'; // Assuming 'vitest' is used for assertions
import PopularTitle from '@/components/Popular-section/PopilarTitle'; // Adjust path as needed
// import leftIcon from '../../assets/icon/Left-Arrow.svg'; // Adjust path as needed
// import rightIcon from '../../assets/icon/Right-Arrow.svg'; // Adjust path as needed

describe('PopularTitle Component', () => {
it('renders PopularTitle component with given props', () => {
// Mock functions for left and right arrow clicks
const mockLeftArrowClick = () => {};
const mockRightArrowClick = () => {};

render(
<PopularTitle
section="Popular Section"
onLeftArrowClick={mockLeftArrowClick}
onRightArrowClick={mockRightArrowClick}
/>
);

expect(screen.getByText('Popular Section')).toBeInTheDocument();

const leftArrow = screen.getByAltText('Left Arrow Icon');
expect(leftArrow).toBeInTheDocument();

const rightArrow = screen.getByAltText('Right Arrow Icon');
expect(rightArrow).toBeInTheDocument();

// Simulate click events on arrows (you may need to adjust this part based on your testing environment)
leftArrow.click();
rightArrow.click();
});
});
54 changes: 0 additions & 54 deletions src/__test__/test.tsx

This file was deleted.

0 comments on commit ffc18fd

Please sign in to comment.