-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Popup): accept SVG as anchor (#2946)
- Loading branch information
Showing
24 changed files
with
191 additions
and
77 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
packages/react-ui/.creevey/images/Hint/With SVG Icon/hover/chrome/open.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
packages/react-ui/.creevey/images/Hint/With SVG Icon/idle/chrome/idle.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
54 changes: 36 additions & 18 deletions
54
packages/react-ui/components/Hint/__tests__/Hint-test.tsx
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,36 +1,54 @@ | ||
import { mount } from 'enzyme'; | ||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { render, screen } from '@testing-library/react'; | ||
|
||
import { Hint } from '../Hint'; | ||
|
||
describe('Hint', () => { | ||
it('render without crash', () => { | ||
const wrapper = mount<Hint>(<Hint text="world">Hello</Hint>); | ||
it('should render without crash', () => { | ||
const hintChildrenText = 'Hello'; | ||
render(<Hint text="world">{hintChildrenText}</Hint>); | ||
|
||
expect(wrapper).toHaveLength(1); | ||
const hintChildren = screen.getByText(hintChildrenText); | ||
expect(hintChildren).toBeInTheDocument(); | ||
}); | ||
|
||
it('controlled opening only if manual prop passed', () => { | ||
const wrapper = mount<Hint>( | ||
<Hint opened text="world"> | ||
it('should not open be controlled manually without `manual` prop passed', () => { | ||
const hintText = 'world'; | ||
render( | ||
<Hint opened text={hintText}> | ||
Hello | ||
</Hint>, | ||
); | ||
|
||
expect(wrapper.state('opened')).toBe(false); | ||
const hintContent = screen.queryByText(hintText); | ||
expect(hintContent).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('manual opening', () => { | ||
const wrapper = mount<Hint>( | ||
<Hint manual text="world"> | ||
Hello | ||
</Hint>, | ||
); | ||
it('should open hint manually', () => { | ||
const hintText = 'world'; | ||
const Component = () => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
return ( | ||
<> | ||
<Hint opened={isOpen} manual text="world"> | ||
Hello | ||
</Hint> | ||
<button onClick={() => setIsOpen(true)}>open manually</button> | ||
</> | ||
); | ||
}; | ||
|
||
render(<Component />); | ||
|
||
expect(wrapper.state('opened')).toBe(false); | ||
const hintContent = screen.queryByText(hintText); | ||
expect(hintContent).not.toBeInTheDocument(); | ||
|
||
wrapper.setProps({ opened: true }); | ||
const openButton = screen.getByRole('button'); | ||
userEvent.click(openButton); | ||
|
||
expect(wrapper.state('opened')).toBe(true); | ||
const hintContentUpdated = screen.getByText(hintText); | ||
expect(hintContentUpdated).toBeInTheDocument(); | ||
}); | ||
}); |
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
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
Oops, something went wrong.