@tarojs/components
Advanced tools
Comparing version 0.0.36 to 0.0.37
{ | ||
"name": "@tarojs/components", | ||
"version": "0.0.36", | ||
"version": "0.0.37", | ||
"description": "", | ||
"main": "./dist/index.js", | ||
"module": "./src/components/index.js", | ||
"typings": "./types/index.d.ts", | ||
"files": [ | ||
"src/components", | ||
"dist", | ||
"utils" | ||
"utils", | ||
"types" | ||
], | ||
@@ -28,5 +30,7 @@ "scripts": { | ||
"dependencies": { | ||
"@types/react": "^16.3.16", | ||
"classnames": "^2.2.5", | ||
"nervjs": "^1.2.16", | ||
"omit.js": "^1.0.0", | ||
"react": "16.3.0", | ||
"weui": "^1.1.2" | ||
@@ -33,0 +37,0 @@ }, |
@@ -5,2 +5,5 @@ import Nerv from 'nervjs' | ||
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) | ||
const hoverStartTime = 50 | ||
const hoverStayTime = 400 | ||
describe('View', () => { | ||
@@ -14,21 +17,48 @@ it('render View', () => { | ||
it('touchStart View', () => { | ||
it('should set hoverClass after touchStart and remove it after touchEnd', async () => { | ||
const hoverClass = 'hoverclass' | ||
const onTouchStart = jest.fn() | ||
const view = <View hoverClass='test' onTouchStart={onTouchStart}> hover View</View> | ||
const onTouchEnd = jest.fn() | ||
let viewIns | ||
const view = <View className='class' ref={c => (viewIns = c)} hoverClass={hoverClass} onTouchStart={onTouchStart} onTouchEnd={onTouchEnd}> hover View</View> | ||
const component = renderIntoDocument(view) | ||
const dom = Nerv.findDOMNode(component) | ||
Simulate.touchStart(dom) | ||
expect(onTouchStart).toHaveBeenCalled() | ||
expect(onTouchStart).toHaveBeenCalled() | ||
Simulate.touchEnd(dom) | ||
await delay(hoverStartTime) | ||
expect(dom.getAttribute('class')).not.toContain(hoverClass) | ||
Simulate.touchStart(dom) | ||
await delay(hoverStartTime) | ||
expect(viewIns.state.touch).toEqual(true) | ||
expect(dom.getAttribute('class')).toContain(hoverClass) | ||
Simulate.touchEnd(dom) | ||
expect(onTouchEnd).toHaveBeenCalled() | ||
Simulate.touchStart(dom) | ||
await delay(hoverStayTime) | ||
expect(dom.getAttribute('class')).toContain(hoverClass) | ||
Simulate.touchEnd(dom) | ||
await delay(hoverStayTime) | ||
expect(dom.getAttribute('class')).not.toContain(hoverClass) | ||
}) | ||
it('touchEnd View', () => { | ||
const onTouchEnd = jest.fn() | ||
const view = <View hoverClass='test' onTouchEnd={onTouchEnd}> hover View</View> | ||
it('should not execute set hoverClass when hoverClass is undefined', async () => { | ||
let viewIns | ||
const view = <View className='class' ref={c => (viewIns = c)}> hover View</View> | ||
const component = renderIntoDocument(view) | ||
const dom = Nerv.findDOMNode(component) | ||
Simulate.touchStart(dom) | ||
expect(viewIns.state.touch).toEqual(false) | ||
await delay(hoverStartTime) | ||
expect(viewIns.state.hover).toEqual(false) | ||
Simulate.touchEnd(dom) | ||
expect(onTouchEnd).toHaveBeenCalled() | ||
await delay(hoverStayTime) | ||
expect(viewIns.state.hover).toEqual(false) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
382140
103
9314
10
+ Added@types/react@^16.3.16
+ Addedreact@16.3.0
+ Added@types/prop-types@15.7.13(transitive)
+ Added@types/react@16.14.62(transitive)
+ Added@types/scheduler@0.16.8(transitive)
+ Addedasap@2.0.6(transitive)
+ Addedcore-js@1.2.7(transitive)
+ Addedcsstype@3.1.3(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedfbjs@0.8.18(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisomorphic-fetch@2.2.1(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addednode-fetch@1.7.3(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedpromise@7.3.1(transitive)
+ Addedprop-types@15.8.1(transitive)
+ Addedreact@16.3.0(transitive)
+ Addedreact-is@16.13.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedua-parser-js@0.7.39(transitive)
+ Addedwhatwg-fetch@3.6.20(transitive)