-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(project): fix header content shift due to image load
- Loading branch information
1 parent
a8f6733
commit 0dbde3f
Showing
6 changed files
with
29 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
import React from 'react'; | ||
import { fireEvent } from '@testing-library/react'; | ||
|
||
import { render } from '../../testUtils'; | ||
|
||
import Logo from './Logo'; | ||
|
||
describe('<Logo/>', () => { | ||
it('renders and matches snapshot', () => { | ||
const { container } = render(<Logo src="123" />); | ||
const { container } = render(<Logo src="123" onLoad={jest.fn()} />); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
it('calls the onLoad function after the image has been loaded', () => { | ||
const onLoad = jest.fn(); | ||
const { getByAltText } = render(<Logo src="testimage" onLoad={onLoad} />); | ||
|
||
fireEvent.load(getByAltText('logo')); | ||
|
||
expect(onLoad).toBeCalledTimes(1); | ||
}); | ||
|
||
it('calls the onLoad function when the image fails to load', () => { | ||
const onLoad = jest.fn(); | ||
const { getByAltText } = render(<Logo src="testimage" onLoad={onLoad} />); | ||
|
||
fireEvent.error(getByAltText('logo')); | ||
|
||
expect(onLoad).toBeCalledTimes(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters