|
1 | 1 | import { createPassThroughPropsTest } from '@shared/tests/utils';
|
2 |
| -import { act, render } from '@testing-library/react'; |
| 2 | +import { act, render, screen, fireEvent, cleanStaticAreaAfterEachTest, waitFor } from '@shared/tests'; |
3 | 3 | import { AnalyticalTable } from '@ui5/webcomponents-react/lib/AnalyticalTable';
|
4 | 4 | import { TableSelectionBehavior } from '@ui5/webcomponents-react/lib/TableSelectionBehavior';
|
5 | 5 | import { TableSelectionMode } from '@ui5/webcomponents-react/lib/TableSelectionMode';
|
@@ -142,24 +142,25 @@ const dataTree = [
|
142 | 142 | ];
|
143 | 143 |
|
144 | 144 | describe('AnalyticalTable', () => {
|
145 |
| - test('test Asc desc', () => { |
146 |
| - const wrapper = mount(<AnalyticalTable data={data} title={'Test'} columns={columns} />); |
| 145 | + cleanStaticAreaAfterEachTest(); |
147 | 146 |
|
148 |
| - expect(wrapper.render()).toMatchSnapshot(); |
| 147 | + beforeEach(() => { |
| 148 | + window = Object.assign(window, { innerWidth: 1440 }); |
| 149 | + }); |
149 | 150 |
|
150 |
| - // test asc function inside the popover element |
151 |
| - let component = wrapper.find('ui5-li').at(1).instance(); |
152 |
| - // @ts-ignore |
153 |
| - component.click(); |
| 151 | + test('test Asc desc', async () => { |
| 152 | + const { asFragment } = render(<AnalyticalTable data={data} title={'Test'} columns={columns} />); |
154 | 153 |
|
155 |
| - expect(wrapper.render()).toMatchSnapshot(); |
| 154 | + expect(asFragment()).toMatchSnapshot(); |
| 155 | + |
| 156 | + fireEvent.click(screen.getAllByText('Sort Ascending')[0], { bubbles: false }); |
| 157 | + |
| 158 | + expect(asFragment()).toMatchSnapshot(); |
156 | 159 |
|
157 | 160 | // test desc function inside the popover element
|
158 |
| - component = wrapper.find('ui5-li').at(0).instance(); |
159 |
| - // @ts-ignore |
160 |
| - component.click(); |
| 161 | + fireEvent.click(screen.getAllByText('Sort Descending')[0], { bubbles: false }); |
161 | 162 |
|
162 |
| - expect(wrapper.render()).toMatchSnapshot(); |
| 163 | + expect(asFragment()).toMatchSnapshot(); |
163 | 164 | });
|
164 | 165 |
|
165 | 166 | test('Tree Table', () => {
|
|
0 commit comments