Skip to content

Commit

Permalink
Implemented tests for PastEvent and EventCard components
Browse files Browse the repository at this point in the history
  • Loading branch information
henryhlly committed Sep 26, 2024
1 parent 93dfe93 commit 0545758
Show file tree
Hide file tree
Showing 3 changed files with 9,983 additions and 13,652 deletions.
50 changes: 50 additions & 0 deletions frontend2/components/Home/PastEvents/PastEvent.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { render, screen } from '@/test-utils';
import { PastEvent } from './PastEvent';

describe('Banner component', () => {
const ExampleEvent : PastEvent = {
events: [
{
eventName: 'Pool Night 1',
eventDescription: 'Enjoy a night of pure pool goodness at the Orange Club. $9 entry. Our execs will be there feel free to come say hi!',
imgUrl: '/event_example.svg'
},
{
eventName: 'Pool Night 2',
eventDescription: 'Enjoy a night of pure pool goodness at the Orange Club. $9 entry. Our execs will be there feel free to come say hi!',
imgUrl: '/event_example.svg'
},
{
eventName: 'Pool Night 3',
eventDescription: 'Enjoy a night of pure pool goodness at the Orange Club. $9 entry. Our execs will be there feel free to come say hi!',
imgUrl: '/event_example.svg'
},
{
eventName: 'Pool Night 4',
eventDescription: 'Enjoy a night of pure pool goodness at the Orange Club. $9 entry. Our execs will be there feel free to come say hi!',
imgUrl: '/event_example.svg'
},
{
eventName: 'Pool Night 5',
eventDescription: 'Enjoy a night of pure pool goodness at the Orange Club. $9 entry. Our execs will be there feel free to come say hi!',
imgUrl: '/event_example.svg'
},
{
eventName: 'Pool Night 6',
eventDescription: 'Enjoy a night of pure pool goodness at the Orange Club. $9 entry. Our execs will be there feel free to come say hi!',
imgUrl: '/event_example.svg'
},

]
}
it('renders correctly', () => {
render(
<PastEvent
events = {ExampleEvent.events}
/>
);
ExampleEvent.events.forEach(event => {
expect(screen.getByText(event.eventName)).toBeInTheDocument();
});
});
});
41 changes: 41 additions & 0 deletions frontend2/components/Shared/Event/Card/EventCard.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { render, screen } from '@/test-utils';
import { EventCard, Event } from './EventCard';

// Test short event name and description
describe('Short Event Name and Description', () => {
const placeholderEvent : Event = {
eventName: 'PoolNight',
eventDescription: 'Pool at Orange',
imgUrl: '/event_example.svg'
};
it('renders correctly', () => {
render(
<EventCard
event={placeholderEvent}
/>
);
expect(screen.getByText(placeholderEvent.eventName)).toBeInTheDocument();
expect(screen.getByText(placeholderEvent.eventDescription)).toBeInTheDocument();
expect(screen.getByAltText(placeholderEvent.eventName)).toBeInTheDocument();
});
});


// Test short event name and description
describe('Long Event Name and Description', () => {
const placeholderEvent : Event = {
eventName: 'Pool Night on a Wednesday Night, MEMBERS ONLY!!! SUPER EXCLUSIVE, SUPER FUN, SUPER AWESOME',
eventDescription: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
imgUrl: '/event_example.svg'
};
it('renders correctly', () => {
render(
<EventCard
event={placeholderEvent}
/>
);
expect(screen.getByText(placeholderEvent.eventName)).toBeInTheDocument();
expect(screen.getByText(placeholderEvent.eventDescription)).toBeInTheDocument();
expect(screen.getByAltText(placeholderEvent.eventName)).toBeInTheDocument();
});
});
Loading

0 comments on commit 0545758

Please sign in to comment.