Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIIN-1671 create JEST/RTL for ItemsListRow.js #2090

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions src/Instance/ItemsList/ItemsListRow.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React from 'react';
import { screen } from '@testing-library/react';

import '../../../test/jest/__mock__/currencyData.mock';
import '../../../test/jest/__mock__/stripesConfig.mock';
import '../../../test/jest/__mock__/stripesCore.mock';
import { renderWithIntl } from '../../../test/jest/helpers';

import ItemsListRow from './ItemsListRow';

jest.mock('react-beautiful-dnd', () => ({
Draggable: jest.fn().mockImplementation(({ children }) => children({
draggableProps: {
style: {},
},
innerRef: jest.fn(),
},
{
isDragging: false
}))
.mockImplementationOnce(({ children }) => children({
draggableProps: {
style: {},
},
innerRef: jest.fn(),
},
{
isDragging: true
})),
}));

const mockisItemsDragSelected = jest.fn();
const defaultProps = {
rowClass: [
'RowClass 1',
'RowClass 2',
'RowClass 3'
],
cells: [
'cell 1',
'cell 2',
'cell 3'
],
rowIndex: 1,
rowData: {
id: 'testID'
},
rowProps: {
draggable: false,
isItemsDragSelected: mockisItemsDragSelected,
getDraggingItems: jest.fn().mockReturnValue({
items: {
length: 5
}
})
},
};

const renderItemsListRow = (props) => {
let container = document.getElementById('ModuleContainer');
if (!container) {
container = document.createElement('div');
container.setAttribute('id', 'ModuleContainer');
document.body.appendChild(container);
}
renderWithIntl(<ItemsListRow {...props} />);
};


describe('ItemsListRow', () => {
it('new mo should render isDragging of snapshot is true', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what "new mo" means; is this a typo? I don't understand how the description "isDragging ... is true" relates to the expect clause

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have cleared all typos. Changes made as per your suggestions. Updated test description.

renderItemsListRow(defaultProps);
expect(screen.queryByText('ui-inventory.moveItems.move.items.count')).toBeInTheDocument();
});
it('child should render isDragging of snapshot is false', () => {
renderItemsListRow(defaultProps);
expect(screen.getByRole('row', { name: 'cell 1cell 2cell 3' })).toBeInTheDocument();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how the description "isDragging ... is false" relates to the expect clause.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have cleared all typos. Changes made as per your suggestions.

});
});