|
| 1 | +/* eslint-disable testing-library/no-container */ |
| 2 | +/* eslint-disable testing-library/no-node-access */ |
| 3 | +import { mockAppRoot } from '@rocket.chat/mock-providers'; |
| 4 | +import { render, waitFor } from '@testing-library/react'; |
| 5 | + |
| 6 | +import TeamsChannels from './TeamsChannels'; |
| 7 | +import { createFakeRoom } from '../../../../../tests/mocks/data'; |
| 8 | + |
| 9 | +jest.mock('../../../../lib/rooms/roomCoordinator', () => ({ |
| 10 | + roomCoordinator: { |
| 11 | + getRouteLink: () => undefined, |
| 12 | + }, |
| 13 | +})); |
| 14 | + |
| 15 | +const mainRoom = createFakeRoom({ name: 'Main Room' }); |
| 16 | +const fakeRooms = Array.from({ length: 10 }, (_, index) => createFakeRoom({ t: 'c', name: `Fake Room ${index}` })); |
| 17 | + |
| 18 | +beforeEach(() => { |
| 19 | + Object.defineProperty(window, 'getComputedStyle', { |
| 20 | + value: () => { |
| 21 | + return { |
| 22 | + getPropertyPriority: () => undefined, |
| 23 | + getPropertyValue: () => undefined, |
| 24 | + }; |
| 25 | + }, |
| 26 | + }); |
| 27 | +}); |
| 28 | + |
| 29 | +// TODO: Replace this with the storybook & snapshot |
| 30 | +it('should render scrollbars', async () => { |
| 31 | + const { container } = render( |
| 32 | + <TeamsChannels |
| 33 | + text='' |
| 34 | + type='all' |
| 35 | + reload={() => undefined} |
| 36 | + loadMoreItems={() => undefined} |
| 37 | + setText={() => undefined} |
| 38 | + setType={() => undefined} |
| 39 | + onClickClose={() => undefined} |
| 40 | + onClickAddExisting={() => undefined} |
| 41 | + onClickView={() => undefined} |
| 42 | + onClickCreateNew={() => undefined} |
| 43 | + total={fakeRooms.length} |
| 44 | + loading={false} |
| 45 | + mainRoom={mainRoom} |
| 46 | + channels={fakeRooms} |
| 47 | + />, |
| 48 | + { |
| 49 | + wrapper: mockAppRoot().build(), |
| 50 | + }, |
| 51 | + ); |
| 52 | + |
| 53 | + await waitFor(() => { |
| 54 | + expect(container.querySelector('[data-overlayscrollbars]')).toBeInTheDocument(); |
| 55 | + }); |
| 56 | + |
| 57 | + expect(container.querySelector('[data-overlayscrollbars]')).toBeInTheDocument(); |
| 58 | +}); |
0 commit comments