Skip to content

Commit

Permalink
chore: enabling/fixing skipped tests (#4758)
Browse files Browse the repository at this point in the history
  • Loading branch information
esauerbo authored Nov 17, 2023
1 parent 9551eb8 commit 29672aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { render, screen } from '@testing-library/react';
import { render, screen, waitFor } from '@testing-library/react';
import * as Storage from 'aws-amplify/storage';

import { ComponentClassName } from '@aws-amplify/ui';
Expand Down Expand Up @@ -64,9 +64,7 @@ describe('StorageImage', () => {
expect(img).toHaveAttribute('src', imgURL);
});

// @todo-migration fix
// eslint-disable-next-line jest/no-disabled-tests
it.skip('should set image src attribute to fallbackSrc and invoke onGetStorageError when Storage.get is rejected', async () => {
it('should set image src attribute to fallbackSrc and invoke onGetStorageError when Storage.get is rejected', async () => {
jest.restoreAllMocks();
jest.spyOn(Storage, 'getUrl').mockRejectedValue(errorMessage);
const onStorageError = jest.fn();
Expand All @@ -79,10 +77,12 @@ describe('StorageImage', () => {
onStorageGetError={onStorageError}
/>
);
await waitFor(() => {
const img = screen.getByRole('img');
expect(img).toHaveAttribute('src', fallbackSrc);

const img = await screen.findByRole('img');
expect(onStorageError).toHaveBeenCalledTimes(1);
expect(onStorageError).toHaveBeenCalledWith(errorMessage);
expect(img).toHaveAttribute('src', fallbackSrc);
expect(onStorageError).toHaveBeenCalledTimes(1);
expect(onStorageError).toHaveBeenCalledWith(errorMessage);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ describe('FileRemoveButton', () => {
expect(container).toMatchSnapshot();
});

// @todo-migration fix
// eslint-disable-next-line jest/no-disabled-tests
it.skip('should fire onClick function if the button is clicked on', async () => {
it('should fire onClick function if the button is clicked on', async () => {
const { findByRole } = render(
<FileRemoveButton {...fileRemoveButtonProps} />
);

const button = await findByRole('button');
userEvent.click(button);
await userEvent.click(button);
expect(onClick).toHaveBeenCalledTimes(1);
});

Expand Down

0 comments on commit 29672aa

Please sign in to comment.