PR-722301: Adding Input and List Components testing.

This commit is contained in:
2023-10-12 00:08:05 +00:00
parent 966ef13300
commit d1da40fdd2
7 changed files with 96 additions and 3 deletions

View File

@ -0,0 +1,11 @@
import React from 'react';
import { Input } from '@components';
describe('Testing Input Component', () => {
beforeEach(() => {
cy.mount(<Input placeholder='Test Placeholder' />);
});
it('Show right text on placeholder', () => {
cy.get('input').should('have.attr', 'placeholder', 'Test Placeholder');
});
})

View File

@ -0,0 +1,18 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { Input } from '@components';
describe('Testing Input Component', () => {
beforeEach(() => {
// fetchMock.resetMocks();
render(<Input placeholder='Test Placeholder'/>)
});
it('Show right text on placeholder', async () => {
/* fetchMock.mockResponseOnce(JSON.stringify({
//First Data Fetch
data: 'data'
})); */
const input = screen.getByPlaceholderText('Test Placeholder');
expect(input).toBeInTheDocument();
})
})

View File

@ -0,0 +1,24 @@
import React from 'react';
import { List, Status } from '@components';
describe('Testing List Component', () => {
beforeEach(() => {
cy.mount(<List list={[
{
name: 'First Item',
status: Status.DONE
},
{
name: 'Second Item',
status: Status.TODO
},
{
name: 'Third Item',
status: Status.DONE
}
]} />);
})
it('Show All Items in a list', () => {
cy.get('input').should('have.length', 3);
})
})

View File

@ -0,0 +1,31 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { List, Status } from '@components';
describe('Testing List Component', () => {
beforeEach(() => {
// fetchMock.resetMocks();
render(<List list={[
{
name: 'First Item',
status: Status.DONE
},
{
name: 'Second Item',
status: Status.TODO
},
{
name: 'Third Item',
status: Status.DONE
}
]} />)
});
it('Show All Items in a list', async () => {
/* fetchMock.mockResponseOnce(JSON.stringify({
//First Data Fetch
data: 'data'
})); */
const items = screen.getAllByRole('checkbox');
expect(items).toHaveLength(3);
})
})