This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #851 from ZupIT/issue/user-group-pagination
Adding pagination for User Groups menu items
- Loading branch information
Showing
13 changed files
with
189 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,44 +15,52 @@ | |
*/ | ||
|
||
import React from 'react'; | ||
import { render, screen, waitFor } from 'unit-test/testUtils'; | ||
import { UserGroupItem } from './fixtures'; | ||
import { FetchMock } from 'jest-fetch-mock/types'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { render, screen } from 'unit-test/testUtils'; | ||
import * as StateHooks from 'core/state/hooks'; | ||
import Menu from '../index'; | ||
|
||
test('render Menu users groups default', async () => { | ||
test('render Menu user groups default', async () => { | ||
render( | ||
<Menu | ||
onSearch={jest.fn()} | ||
onCreate={jest.fn()} | ||
onSelect={jest.fn()} | ||
isLoading={false} | ||
selectedItems={null} | ||
items={[]} | ||
/> | ||
); | ||
|
||
const menu = screen.getByTestId('users-groups-menu'); | ||
const emptyItems = screen.getByText('No User group was found'); | ||
const menu = await screen.findByTestId('user-groups-action'); | ||
const emptyItems = await screen.findByText('No User group was found'); | ||
|
||
expect(menu).toBeInTheDocument(); | ||
expect(emptyItems).toBeInTheDocument(); | ||
}); | ||
|
||
test('render Menu items', async () => { | ||
test('render Menu user groups items', async () => { | ||
jest.spyOn(StateHooks, 'useGlobalState').mockImplementation(() => ({ | ||
list: { | ||
content: [{ | ||
id: '1', | ||
name: 'group', | ||
page: 0, | ||
size: 1, | ||
totalPages: 1, | ||
last: true, | ||
users: [{ | ||
id: '2', | ||
name: 'Charles', | ||
email: '[email protected]', | ||
createdAt: '2021-01-01 01:01' | ||
}] | ||
}] | ||
}, | ||
})); | ||
|
||
render( | ||
<Menu | ||
onSearch={jest.fn()} | ||
onCreate={jest.fn()} | ||
onSelect={jest.fn()} | ||
isLoading={false} | ||
selectedItems={null} | ||
items={UserGroupItem} | ||
/> | ||
); | ||
|
||
const menuItem = screen.getByTestId('group-menu-item-1'); | ||
const menuItem = await screen.findByTestId('group-menu-item-1'); | ||
expect(menuItem).toBeInTheDocument(); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.