-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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', () => { | ||
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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have cleared all typos. Changes made as per your suggestions. |
||
}); | ||
}); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.