diff --git a/src/components/swipe-action/__snapshots__/index.test.js.snap b/src/components/swipe-action/__snapshots__/index.test.js.snap new file mode 100644 index 000000000..f428f8627 --- /dev/null +++ b/src/components/swipe-action/__snapshots__/index.test.js.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SwipeAction Snap render options 1`] = `"
AtSwipeAction 一般使用场景
取消
确认
"`; diff --git a/src/components/swipe-action/index.test.js b/src/components/swipe-action/index.test.js new file mode 100644 index 000000000..fa2b591cf --- /dev/null +++ b/src/components/swipe-action/index.test.js @@ -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 一般使用场景 + + ) + expect(component).toMatchSnapshot() + }) +}) + +describe('SwipeAction Behavior ', () => { + it('SwipeAction onClick', () => { + const onClick = jest.fn() + + const component = renderIntoDocument( + + AtSwipeAction 一般使用场景 + + ) + const componentDom = findDOMNode(component, 'at-swipe-action') + + const optionDom = componentDom.querySelector('.at-swipe-action__option') + + Simulate.click(optionDom) + + expect(onClick).toBeCalled() + }) +})