Skip to content

Commit

Permalink
added testing for scroll functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
shayanaijaz committed Sep 29, 2023
1 parent 379757d commit 84b7b37
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion client/src/components/Jobs/Jobs.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { render } from '@testing-library/react';
import { fireEvent, render, waitFor } from '@testing-library/react';
import Jobs from './Jobs';
import { createMemoryHistory } from 'history';
import { default as jobsList } from './Jobs.fixture';
Expand Down Expand Up @@ -135,4 +135,35 @@ describe('Jobs View', () => {
const { getByText } = renderJobsComponent(store, history);
expect(getByText(/unable to retrieve your jobs/)).toBeDefined();
});

it('should dispatch another get jobs event on scroll with proper offset', async () => {
const store = mockStore({
notifications,
jobs: { ...jobs, list: jobsList },
workbench: { ...workbench, config: { hideDataFiles: false } },
apps: {
appIcons: {},
},
});

const { container } = render(
<Provider store={store}>
<BrowserRouter>
<Jobs />
</BrowserRouter>
</Provider>
);

const scrollContainer = container.querySelector('.table-container');

fireEvent.scroll(scrollContainer, { target: { scrollTop: 1 } });

expect(store.getActions()).toEqual([
{ type: 'GET_JOBS', params: { offset: 0, queryString: '' } },
{
type: 'GET_JOBS',
params: { offset: jobsList.length, queryString: '' },
},
]);
});
});

0 comments on commit 84b7b37

Please sign in to comment.