-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (37 loc) · 1 KB
/
index.js
File metadata and controls
47 lines (37 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* External dependencies
*/
import { act, render } from '@testing-library/react';
/**
* Internal dependencies
*/
import Popover from '../';
describe( 'Popover', () => {
afterEach( () => {
if ( document.activeElement ) {
document.activeElement.blur();
}
} );
it( 'should allow focus-on-open behavior to be disabled', () => {
expect( document.activeElement ).toBe( document.body );
act( () => {
render( <Popover focusOnMount={ false } /> );
jest.advanceTimersByTime( 1 );
} );
expect( document.activeElement ).toBe( document.body );
} );
it( 'should render content', () => {
let result;
act( () => {
result = render( <Popover>Hello</Popover> );
} );
expect( result.container.querySelector( 'span' ) ).toMatchSnapshot();
} );
it( 'should pass additional props to portaled element', () => {
let result;
act( () => {
result = render( <Popover role="tooltip">Hello</Popover> );
} );
expect( result.container.querySelector( 'span' ) ).toMatchSnapshot();
} );
} );