fix: Center each import icon and add a tooltip II (#14192)

This commit is contained in:
Lyndsi Kay Williams
2021-04-20 18:59:48 -05:00
committed by GitHub
parent 392d8a8107
commit a846015f4d
11 changed files with 252 additions and 17 deletions

View File

@@ -22,6 +22,10 @@ import configureStore from 'redux-mock-store';
import fetchMock from 'fetch-mock';
import { Provider } from 'react-redux';
import { styledMount as mount } from 'spec/helpers/theming';
import { render, screen, cleanup } from 'spec/helpers/testing-library';
import userEvent from '@testing-library/user-event';
import { QueryParamProvider } from 'use-query-params';
import * as featureFlags from 'src/featureFlags';
import DatabaseList from 'src/views/CRUD/data/database/DatabaseList';
import DatabaseModal from 'src/views/CRUD/data/database/DatabaseModal';
@@ -178,3 +182,43 @@ describe('DatabaseList', () => {
);
});
});
describe('RTL', () => {
async function renderAndWait() {
const mounted = act(async () => {
render(
<QueryParamProvider>
<DatabaseList user={mockUser} />
</QueryParamProvider>,
{ useRedux: true },
);
});
return mounted;
}
let isFeatureEnabledMock;
beforeEach(async () => {
isFeatureEnabledMock = jest
.spyOn(featureFlags, 'isFeatureEnabled')
.mockImplementation(() => true);
await renderAndWait();
});
afterEach(() => {
cleanup();
isFeatureEnabledMock.mockRestore();
});
it('renders an "Import Database" tooltip under import button', async () => {
const importButton = screen.getByTestId('import-button');
userEvent.hover(importButton);
await screen.findByRole('tooltip');
const importTooltip = screen.getByRole('tooltip', {
name: 'Import databases',
});
expect(importTooltip).toBeInTheDocument();
});
});