-
Notifications
You must be signed in to change notification settings - Fork 753
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
Showing
2 changed files
with
62 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`SwipeAction Snap render options 1`] = `"<div class=\\"at-swipe-action swipe-action--test\\"><div style=\\"transform:translate3d(0px,0,0);\\" class=\\"at-swipe-action__content animtion\\"><div class=\\"normal\\">AtSwipeAction 一般使用场景</div></div><div class=\\"at-swipe-action__options\\"><div style=\\"background-color:#6190E8;\\" class=\\"at-swipe-action__option cancel\\"><span class=\\"taro-text option__text\\">取消</span></div><div style=\\"background-color:#FF4949;\\" class=\\"at-swipe-action__option confirm\\"><span class=\\"taro-text option__text\\">确认</span></div></div></div>"`; |
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,59 @@ | ||
import Nerv, { findDOMNode } from 'nervjs' | ||
import { renderToString } from 'nerv-server' | ||
import { Simulate, renderIntoDocument } from 'nerv-test-utils' | ||
|
||
import { View } from '@tarojs/components' | ||
|
||
import AtSwipeAction from '../../../.temp/components/swipe-action/index' | ||
|
||
const OPTIONS = [ | ||
{ | ||
text: '取消', | ||
className: 'cancel', | ||
style: { | ||
backgroundColor: '#6190E8' | ||
} | ||
}, | ||
{ | ||
text: '确认', | ||
className: 'confirm', | ||
style: { | ||
backgroundColor: '#FF4949' | ||
} | ||
} | ||
] | ||
|
||
describe('SwipeAction Snap', () => { | ||
it('render options', () => { | ||
const component = renderToString( | ||
<AtSwipeAction | ||
className='swipe-action--test' | ||
disabled | ||
autoClose | ||
options={OPTIONS} | ||
> | ||
<View className='normal'>AtSwipeAction 一般使用场景</View> | ||
</AtSwipeAction> | ||
) | ||
expect(component).toMatchSnapshot() | ||
}) | ||
}) | ||
|
||
describe('SwipeAction Behavior ', () => { | ||
it('SwipeAction onClick', () => { | ||
const onClick = jest.fn() | ||
|
||
const component = renderIntoDocument( | ||
<AtSwipeAction options={OPTIONS} onClick={onClick}> | ||
<View className='normal'>AtSwipeAction 一般使用场景</View> | ||
</AtSwipeAction> | ||
) | ||
const componentDom = findDOMNode(component, 'at-swipe-action') | ||
|
||
const optionDom = componentDom.querySelector('.at-swipe-action__option') | ||
|
||
Simulate.click(optionDom) | ||
|
||
expect(onClick).toBeCalled() | ||
}) | ||
}) |