-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* BlockUI Jest test * BlockUI Jest test
- Loading branch information
Showing
4 changed files
with
280 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import '@testing-library/jest-dom'; | ||
import { act, render } from '@testing-library/react'; | ||
import * as React from 'react'; | ||
import { snapshotParent } from '../../test'; | ||
import { Panel } from '../panel/Panel'; | ||
import { BlockUI } from './BlockUI'; | ||
|
||
describe('BlockUI', () => { | ||
snapshotParent(<BlockUI blocked={true} fullScreen />, 'block fullscreen'); | ||
snapshotParent( | ||
<BlockUI blocked={true}> | ||
<Panel>blocked</Panel> | ||
</BlockUI>, | ||
'block panel' | ||
); | ||
snapshotParent( | ||
<BlockUI blocked={false}> | ||
<Panel>unblocked</Panel> | ||
</BlockUI>, | ||
'unblock panel' | ||
); | ||
test('block and unblock panel events', async () => { | ||
// Arrange | ||
const ref = React.createRef(); | ||
const { container } = render( | ||
<BlockUI ref={ref} blocked={false}> | ||
<Panel>unblocked</Panel> | ||
</BlockUI> | ||
); | ||
|
||
// Act | ||
act(() => { | ||
ref.current.block(); | ||
ref.current.getElement(); | ||
}); | ||
|
||
// Assert | ||
expect(container).toMatchSnapshot('blocked-event'); | ||
|
||
// Act | ||
act(() => { | ||
ref.current.unblock(); | ||
}); | ||
|
||
// Assert | ||
expect(container).toMatchSnapshot('unblocked-event'); | ||
}); | ||
test('block and unblock fullscreen events', async () => { | ||
// Arrange | ||
const ref = React.createRef(); | ||
const { container } = render(<BlockUI ref={ref} blocked={false} fullScreen></BlockUI>); | ||
|
||
// Act | ||
act(() => { | ||
ref.current.block(); | ||
}); | ||
|
||
// Assert | ||
expect(container.parentElement).toMatchSnapshot('blocked-event-fullscreen'); | ||
|
||
// Act | ||
act(() => { | ||
ref.current.unblock(); | ||
}); | ||
|
||
// Assert | ||
expect(container.parentElement).toMatchSnapshot('unblocked-event-fullscreen'); | ||
}); | ||
}); |
173 changes: 173 additions & 0 deletions
173
components/lib/blockui/__snapshots__/BlockUI.spec.js.snap
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 |
---|---|---|
@@ -0,0 +1,173 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`BlockUI block and unblock fullscreen events: blocked-event-fullscreen 1`] = ` | ||
<body | ||
class="p-overflow-hidden" | ||
> | ||
<div> | ||
<div | ||
class="p-blockui-container" | ||
/> | ||
</div> | ||
<div | ||
class="p-blockui p-component-overlay p-component-overlay-enter p-blockui-document" | ||
style="z-index: 3204;" | ||
/> | ||
</body> | ||
`; | ||
|
||
exports[`BlockUI block and unblock fullscreen events: unblocked-event-fullscreen 1`] = ` | ||
<body | ||
class="p-overflow-hidden" | ||
> | ||
<div> | ||
<div | ||
class="p-blockui-container" | ||
/> | ||
</div> | ||
<div | ||
class="p-blockui p-component-overlay p-component-overlay-enter p-blockui-document p-component-overlay-leave" | ||
style="z-index: 3204;" | ||
/> | ||
</body> | ||
`; | ||
|
||
exports[`BlockUI block and unblock panel events: blocked-event 1`] = ` | ||
<div> | ||
<div | ||
class="p-blockui-container" | ||
> | ||
<div | ||
class="p-panel p-component" | ||
> | ||
<div | ||
aria-hidden="false" | ||
aria-labelledby="pr_id_3_header" | ||
class="p-toggleable-content" | ||
id="pr_id_3_content" | ||
role="region" | ||
> | ||
<div | ||
class="p-panel-content" | ||
> | ||
unblocked | ||
</div> | ||
</div> | ||
</div> | ||
<div | ||
class="p-blockui p-component-overlay p-component-overlay-enter" | ||
style="z-index: 2103;" | ||
/> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`BlockUI block and unblock panel events: unblocked-event 1`] = ` | ||
<div> | ||
<div | ||
class="p-blockui-container" | ||
> | ||
<div | ||
class="p-panel p-component" | ||
> | ||
<div | ||
aria-hidden="false" | ||
aria-labelledby="pr_id_3_header" | ||
class="p-toggleable-content" | ||
id="pr_id_3_content" | ||
role="region" | ||
> | ||
<div | ||
class="p-panel-content" | ||
> | ||
unblocked | ||
</div> | ||
</div> | ||
</div> | ||
<div | ||
class="p-blockui p-component-overlay p-component-overlay-enter p-component-overlay-leave" | ||
style="z-index: 2103;" | ||
/> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`BlockUI block fullscreen 1`] = ` | ||
<body | ||
class="p-overflow-hidden" | ||
> | ||
<div> | ||
<div | ||
class="p-blockui-container" | ||
/> | ||
</div> | ||
<div | ||
class="p-blockui p-component-overlay p-component-overlay-enter p-blockui-document" | ||
style="z-index: 1101;" | ||
/> | ||
</body> | ||
`; | ||
|
||
exports[`BlockUI block panel 1`] = ` | ||
<body | ||
class="" | ||
> | ||
<div> | ||
<div | ||
class="p-blockui-container" | ||
> | ||
<div | ||
class="p-panel p-component" | ||
> | ||
<div | ||
aria-hidden="false" | ||
aria-labelledby="pr_id_1_header" | ||
class="p-toggleable-content" | ||
id="pr_id_1_content" | ||
role="region" | ||
> | ||
<div | ||
class="p-panel-content" | ||
> | ||
blocked | ||
</div> | ||
</div> | ||
</div> | ||
<div | ||
class="p-blockui p-component-overlay p-component-overlay-enter" | ||
style="z-index: 2102;" | ||
/> | ||
</div> | ||
</div> | ||
</body> | ||
`; | ||
|
||
exports[`BlockUI unblock panel 1`] = ` | ||
<body | ||
class="" | ||
> | ||
<div> | ||
<div | ||
class="p-blockui-container" | ||
> | ||
<div | ||
class="p-panel p-component" | ||
> | ||
<div | ||
aria-hidden="false" | ||
aria-labelledby="pr_id_2_header" | ||
class="p-toggleable-content" | ||
id="pr_id_2_content" | ||
role="region" | ||
> | ||
<div | ||
class="p-panel-content" | ||
> | ||
unblocked | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
`; |
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