forked from ant-design/ant-design-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd78ba3
commit fc60355
Showing
8 changed files
with
79 additions
and
51 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,45 +1,45 @@ | ||
import * as React from 'react' | ||
import { render, mockDrag } from 'testing' | ||
import { render, mockDrag, act, waitFor } from 'testing' | ||
import Popup from '..' | ||
|
||
describe('Popup', () => { | ||
test('top swipe should be closed', () => { | ||
test('top swipe should be closed', async () => { | ||
const onClose = jest.fn() | ||
render( | ||
<Popup visible onClose={onClose} position='top' closeOnSwipe> | ||
<div style={{ height: '400px', width: '400px' }}></div> | ||
</Popup> | ||
) | ||
|
||
mockDrag( | ||
await mockDrag( | ||
document.querySelector('.adm-popup') as Element, | ||
new Array(8).fill(0).map((_, i) => { | ||
new Array(4).fill(0).map((_, i) => { | ||
return { | ||
clientY: 400 - 50 * i, | ||
} | ||
}) | ||
}), | ||
5 | ||
) | ||
|
||
expect(onClose).toBeCalledTimes(1) | ||
}) | ||
|
||
test('bottom swipe should be closed', () => { | ||
test('bottom swipe should be closed', async () => { | ||
const onClose = jest.fn() | ||
render( | ||
<Popup visible onClose={onClose} position='bottom' closeOnSwipe> | ||
<div style={{ height: '400px', width: '400px' }}></div> | ||
</Popup> | ||
) | ||
|
||
mockDrag( | ||
await mockDrag( | ||
document.querySelector('.adm-popup') as Element, | ||
new Array(8).fill(0).map((_, i) => { | ||
new Array(6).fill(0).map((_, i) => { | ||
return { | ||
clientY: 50 * i, | ||
} | ||
}) | ||
}), | ||
5 | ||
) | ||
|
||
expect(onClose).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
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