Skip to content

Commit

Permalink
Merge pull request #1185 from KumarNayan/master
Browse files Browse the repository at this point in the history
Test cases for table components
  • Loading branch information
elraphty authored Dec 26, 2023
2 parents d5710cf + f66f575 commit 5433e07
Showing 1 changed file with 107 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import React from 'react';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom';
import { MyTable } from './index.tsx';

const mockBounties = [
{
id: 1,
title: 'Bounty 1',
date: '2023-01-01',
dtgp: 100,
assignee: 'Assignee 1',
assigneeImage: 'assignee-image-1.jpg',
provider: 'Provider 1',
providerImage: 'provider-image-1.jpg',
organization: 'Org 1',
organizationImage: 'org-image-1.jpg',
status: 'open'
}
];

it('renders elements from TableProps in the document', () => {
const { getByText } = render(<MyTable bounties={mockBounties} />);
expect(getByText(mockBounties[0].title)).toBeInTheDocument();
});

it('renders "Sort By:" in the document', () => {
const { getByText } = render(<MyTable bounties={mockBounties} />);
expect(getByText('Sort By:')).toBeInTheDocument();
});

it('renders "Date" twice in the document', () => {
const { getAllByText } = render(<MyTable bounties={mockBounties} />);
expect(getAllByText('Date')).toHaveLength(2);
});

it('renders "Assignee" twice in the document', () => {
const { getAllByText } = render(<MyTable bounties={mockBounties} />);
expect(getAllByText('Assignee')).toHaveLength(2);
});

it('renders "Status" twice in the document', () => {
const { getAllByText } = render(<MyTable bounties={mockBounties} />);
expect(getAllByText('Status')).toHaveLength(2);
});

it('renders "Status:" in the document', () => {
const { getByText } = render(<MyTable bounties={mockBounties} />);
expect(getByText('Status:')).toBeInTheDocument();
});

it('renders "All" in the document', () => {
const { getByText } = render(<MyTable bounties={mockBounties} />);
expect(getByText('All')).toBeInTheDocument();
});

it('renders "Open" in the document', () => {
const { getByText } = render(<MyTable bounties={mockBounties} />);
expect(getByText('Open')).toBeInTheDocument();
});

it('renders "In Progress" in the document', () => {
const { getByText } = render(<MyTable bounties={mockBounties} />);
expect(getByText('In Progress')).toBeInTheDocument();
});

it('renders "Completed" in the document', () => {
const { getByText } = render(<MyTable bounties={mockBounties} />);
expect(getByText('Completed')).toBeInTheDocument();
});

it('renders "Bounty" in the document', () => {
const { getByText } = render(<MyTable bounties={mockBounties} />);
expect(getByText('Bounty')).toBeInTheDocument();
});

it('renders "#DTGP" in the document', () => {
const { getByText } = render(<MyTable bounties={mockBounties} />);
expect(getByText('#DTGP')).toBeInTheDocument();
});

it('renders "Provider" in the document', () => {
const { getByText } = render(<MyTable bounties={mockBounties} />);
expect(getByText('Provider')).toBeInTheDocument();
});

it('renders "Organization" in the document', () => {
const { getByText } = render(<MyTable bounties={mockBounties} />);
expect(getByText('Organization')).toBeInTheDocument();
});

it('renders each element in the table in the document', () => {
const { getByText } = render(<MyTable bounties={mockBounties} />);
expect(getByText(mockBounties[0].title)).toBeInTheDocument();
});

it('renders each element in the table in the document', () => {
const { getByText } = render(<MyTable bounties={mockBounties} />);
mockBounties.forEach((bounty) => {
expect(getByText(bounty.title)).toBeInTheDocument();
expect(getByText(bounty.date)).toBeInTheDocument();
expect(getByText(String(bounty.dtgp))).toBeInTheDocument();
expect(getByText(bounty.assignee)).toBeInTheDocument();
expect(getByText(bounty.provider)).toBeInTheDocument();
expect(getByText(bounty.organization)).toBeInTheDocument();
});
});

0 comments on commit 5433e07

Please sign in to comment.