@enact/ui 3.4.9-experimental-3 → 3.4.9-experimental-7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{build/A11yDecorator → A11yDecorator}/A11yDecorator.d.ts +0 -0
- package/A11yDecorator/A11yDecorator.js +79 -75
- package/A11yDecorator/tests/A11yDecorator-specs.js +90 -128
- package/AnnounceDecorator/Announce.js +136 -80
- package/{build/AnnounceDecorator → AnnounceDecorator}/AnnounceDecorator.d.ts +0 -0
- package/AnnounceDecorator/AnnounceDecorator.js +68 -53
- package/AnnounceDecorator/tests/Announce-specs.js +29 -35
- package/AnnounceDecorator/tests/AnnounceDecorator-specs.js +34 -36
- package/AnnounceDecorator/tests/useAnnounce-specs.js +56 -63
- package/AnnounceDecorator/useAnnounce.js +29 -18
- package/{build/BodyText → BodyText}/BodyText.d.ts +0 -0
- package/BodyText/BodyText.js +108 -96
- package/{build/BodyText → BodyText}/BodyText.module.css +0 -0
- package/BodyText/tests/BodyText-specs.js +67 -76
- package/{build/Button → Button}/Button.d.ts +0 -0
- package/Button/Button.js +236 -215
- package/{build/Button → Button}/Button.module.css +0 -0
- package/CHANGELOG.md +18 -0
- package/{build/Cancelable → Cancelable}/Cancelable.d.ts +0 -0
- package/Cancelable/Cancelable.js +213 -184
- package/Cancelable/cancelHandler.js +36 -29
- package/Cancelable/modalHandler.js +35 -23
- package/Cancelable/tests/Cancelable-specs.js +289 -381
- package/{build/Changeable → Changeable}/Changeable.d.ts +0 -0
- package/Changeable/Changeable.js +137 -161
- package/Changeable/tests/Changeable-specs.js +262 -327
- package/{build/ComponentOverride → ComponentOverride}/ComponentOverride.d.ts +0 -0
- package/ComponentOverride/ComponentOverride.js +21 -24
- package/FloatingLayer/FloatingLayer.js +310 -261
- package/FloatingLayer/FloatingLayerDecorator.js +150 -99
- package/FloatingLayer/Scrim.js +167 -99
- package/{build/FloatingLayer → FloatingLayer}/Scrim.module.css +0 -0
- package/FloatingLayer/index.js +39 -12
- package/FloatingLayer/tests/FloatingLayer-specs.js +24 -27
- package/FloatingLayer/tests/Scrim-specs.js +21 -24
- package/FloatingLayer/useFloatingLayer.js +46 -18
- package/{build/ForwardRef → ForwardRef}/ForwardRef.d.ts +0 -0
- package/ForwardRef/ForwardRef.js +35 -34
- package/{build/GridListImageItem → GridListImageItem}/GridListImageItem.d.ts +0 -0
- package/GridListImageItem/GridListImageItem.js +244 -212
- package/{build/GridListImageItem → GridListImageItem}/GridListImageItem.module.css +0 -0
- package/{build/Group → Group}/Group.d.ts +0 -0
- package/Group/Group.js +186 -168
- package/Group/GroupItem.js +83 -79
- package/Group/tests/Group-specs.js +128 -164
- package/{build/Heading → Heading}/Heading.d.ts +0 -0
- package/Heading/Heading.js +146 -128
- package/{build/Heading → Heading}/Heading.module.css +0 -0
- package/Heading/tests/Heading-specs.js +46 -54
- package/{build/Icon → Icon}/Icon.d.ts +0 -0
- package/Icon/Icon.js +200 -189
- package/{build/Icon → Icon}/Icon.module.css +0 -0
- package/Icon/tests/Icon-specs.js +92 -126
- package/{build/IconButton → IconButton}/IconButton.d.ts +0 -0
- package/IconButton/IconButton.js +213 -181
- package/{build/IconButton → IconButton}/IconButton.module.css +0 -0
- package/{build/Image → Image}/Image.d.ts +0 -0
- package/Image/Image.js +186 -151
- package/{build/Image → Image}/Image.module.css +0 -0
- package/Image/tests/Image-specs.js +49 -51
- package/{build/ImageItem → ImageItem}/ImageItem.d.ts +0 -0
- package/ImageItem/ImageItem.js +165 -149
- package/{build/ImageItem → ImageItem}/ImageItem.module.css +0 -0
- package/ImageItem/tests/ImageItem-specs.js +128 -161
- package/{build/Item → Item}/Item.d.ts +0 -0
- package/Item/Item.js +131 -121
- package/{build/Item → Item}/Item.module.css +0 -0
- package/Item/tests/Item-specs.js +71 -88
- package/{build/LabeledIcon → LabeledIcon}/LabeledIcon.d.ts +0 -0
- package/LabeledIcon/LabeledIcon.js +235 -216
- package/{build/LabeledIcon → LabeledIcon}/LabeledIcon.module.css +0 -0
- package/LabeledIcon/tests/LabeledIcon-specs.js +49 -58
- package/Layout/Cell.js +181 -146
- package/{build/Layout → Layout}/Layout.d.ts +0 -0
- package/Layout/Layout.js +193 -282
- package/{build/Layout → Layout}/Layout.module.css +0 -0
- package/Layout/tests/Layout-specs.js +102 -109
- package/{build/Marquee → Marquee}/Marquee.module.css +0 -0
- package/Marquee/MarqueeBase.js +275 -240
- package/Marquee/MarqueeController.js +327 -292
- package/Marquee/MarqueeDecorator.js +990 -898
- package/{build/Marquee → Marquee}/index.d.ts +0 -0
- package/Marquee/index.js +39 -14
- package/Marquee/tests/Marquee-specs.js +274 -382
- package/{build/Measurable → Measurable}/Measurable.d.ts +0 -0
- package/Measurable/Measurable.js +133 -100
- package/{build/Media → Media}/Media.d.ts +0 -0
- package/Media/Media.js +317 -254
- package/Placeholder/PlaceholderControllerDecorator.js +188 -133
- package/Placeholder/PlaceholderDecorator.js +147 -95
- package/{build/Placeholder → Placeholder}/index.d.ts +0 -0
- package/Placeholder/index.js +27 -9
- package/{build/ProgressBar → ProgressBar}/ProgressBar.d.ts +0 -0
- package/ProgressBar/ProgressBar.js +183 -173
- package/{build/ProgressBar → ProgressBar}/ProgressBar.module.css +0 -0
- package/ProgressBar/tests/ProgressBar-specs.js +80 -109
- package/RadioDecorator/RadioControllerDecorator.js +104 -54
- package/{build/RadioDecorator → RadioDecorator}/RadioDecorator.d.ts +0 -0
- package/RadioDecorator/RadioDecorator.js +176 -117
- package/RadioDecorator/tests/RadioDecorator-specs.js +155 -166
- package/{build/Repeater → Repeater}/Repeater.d.ts +0 -0
- package/Repeater/Repeater.js +157 -133
- package/Repeater/tests/Repeater-specs.js +136 -155
- package/{build/Resizable → Resizable}/Resizable.d.ts +0 -0
- package/Resizable/Resizable.js +145 -101
- package/Routable/Link.js +65 -61
- package/{build/Routable → Routable}/Routable.d.ts +0 -0
- package/Routable/Routable.js +148 -109
- package/Routable/Route.js +37 -27
- package/Routable/Router.js +236 -171
- package/Routable/tests/Router-specs.js +194 -196
- package/Routable/util.js +78 -68
- package/Scrollable/ScrollAnimator.js +138 -112
- package/Scrollable/ScrollThumb.js +52 -42
- package/{build/Scrollable → Scrollable}/ScrollThumb.module.css +0 -0
- package/{build/Scrollable → Scrollable}/Scrollable.d.ts +0 -0
- package/Scrollable/Scrollable.js +1591 -1443
- package/{build/Scrollable → Scrollable}/Scrollable.module.css +0 -0
- package/Scrollable/ScrollableNative.js +1599 -1445
- package/Scrollable/Scrollbar.js +312 -221
- package/{build/Scrollable → Scrollable}/Scrollbar.module.css +0 -0
- package/{build/Scroller → Scroller}/Scroller.d.ts +0 -0
- package/Scroller/Scroller.js +249 -242
- package/{build/Scroller → Scroller}/Scroller.module.css +0 -0
- package/Scroller/ScrollerBasic.js +311 -230
- package/{build/Scroller → Scroller}/UiScroller.module.css +0 -0
- package/Scroller/UiScrollerBase.js +253 -184
- package/{build/Skinnable → Skinnable}/Skinnable.d.ts +0 -0
- package/Skinnable/Skinnable.js +182 -172
- package/Skinnable/tests/Skinnable-specs.js +388 -416
- package/Skinnable/tests/useSkins-specs.js +290 -281
- package/Skinnable/tests/util-specs.js +107 -113
- package/Skinnable/useSkins.js +51 -28
- package/Skinnable/util.js +80 -75
- package/Slider/Knob.js +85 -71
- package/Slider/PositionDecorator.js +232 -162
- package/{build/Slider → Slider}/Slider.d.ts +0 -0
- package/Slider/Slider.js +331 -312
- package/{build/Slider → Slider}/Slider.module.css +0 -0
- package/Slider/utils.js +16 -11
- package/{build/SlotItem → SlotItem}/SlotItem.d.ts +0 -0
- package/SlotItem/SlotItem.js +199 -179
- package/{build/SlotItem → SlotItem}/SlotItem.module.css +0 -0
- package/{build/Slottable → Slottable}/Slottable.d.ts +0 -0
- package/Slottable/Slottable.js +62 -48
- package/Slottable/tests/Slottable-specs.js +232 -284
- package/Slottable/tests/useSlots-specs.js +277 -313
- package/Slottable/useSlots.js +113 -90
- package/{build/Spinner → Spinner}/Spinner.d.ts +0 -0
- package/Spinner/Spinner.js +213 -178
- package/{build/Spinner → Spinner}/Spinner.module.css +0 -0
- package/Spinner/tests/Spinner-specs.js +61 -77
- package/{build/ToggleIcon → ToggleIcon}/ToggleIcon.d.ts +0 -0
- package/ToggleIcon/ToggleIcon.js +134 -123
- package/{build/ToggleIcon → ToggleIcon}/ToggleIcon.module.css +0 -0
- package/ToggleIcon/tests/ToggleIcon-specs.js +52 -71
- package/{build/ToggleItem → ToggleItem}/ToggleItem.d.ts +0 -0
- package/ToggleItem/ToggleItem.js +263 -264
- package/{build/ToggleItem → ToggleItem}/ToggleItem.module.css +0 -0
- package/ToggleItem/tests/ToggleItem-specs.js +87 -87
- package/Toggleable/Toggle.js +70 -43
- package/{build/Toggleable → Toggleable}/Toggleable.d.ts +0 -0
- package/Toggleable/Toggleable.js +219 -244
- package/Toggleable/tests/Toggleable-specs.js +416 -549
- package/Toggleable/useToggle.js +50 -24
- package/Touchable/ClickAllow.js +67 -49
- package/Touchable/Drag.js +199 -170
- package/Touchable/Flick.js +152 -122
- package/Touchable/Hold.js +259 -214
- package/{build/Touchable → Touchable}/Touchable.d.ts +0 -0
- package/Touchable/Touchable.js +643 -651
- package/Touchable/config.js +63 -44
- package/Touchable/state.js +31 -14
- package/Touchable/tests/Touchable-specs.js +462 -526
- package/{build/Transition → Transition}/Transition.d.ts +0 -0
- package/Transition/Transition.js +606 -553
- package/{build/Transition → Transition}/Transition.module.css +0 -0
- package/Transition/tests/Transition-specs.js +123 -138
- package/ViewManager/Arranger.js +82 -40
- package/ViewManager/TransitionGroup.js +502 -419
- package/ViewManager/View.js +383 -298
- package/{build/ViewManager → ViewManager}/ViewManager.d.ts +0 -0
- package/ViewManager/ViewManager.js +352 -296
- package/ViewManager/tests/View-specs.js +176 -275
- package/ViewManager/tests/ViewManager-specs.js +524 -471
- package/ViewManager/tests/test-utils.js +44 -23
- package/{build/VirtualList → VirtualList}/UiVirtualList.module.css +0 -0
- package/VirtualList/UiVirtualListBase.js +1381 -1171
- package/{build/VirtualList → VirtualList}/VirtualList.d.ts +0 -0
- package/VirtualList/VirtualList.js +541 -537
- package/{build/VirtualList → VirtualList}/VirtualList.module.css +0 -0
- package/VirtualList/VirtualListBase.js +37 -10
- package/VirtualList/VirtualListBasic.js +1468 -1241
- package/VirtualList/tests/VirtualList-specs.js +314 -345
- package/{build/index.d.ts → index.d.ts} +0 -0
- package/index.js +1 -0
- package/{build/internal → internal}/IdProvider/IdProvider.d.ts +0 -0
- package/internal/IdProvider/IdProvider.js +76 -54
- package/internal/IdProvider/Provider.js +67 -41
- package/internal/IdProvider/tests/useId-specs.js +64 -78
- package/internal/IdProvider/useId.js +27 -15
- package/{build/internal → internal}/Pure/Pure.d.ts +0 -0
- package/internal/Pure/Pure.js +98 -65
- package/{build/internal → internal}/localized-fonts/localized-fonts.d.ts +0 -0
- package/internal/localized-fonts/localized-fonts.js +179 -159
- package/{build/internal → internal}/selection/selection.d.ts +0 -0
- package/internal/selection/selection.js +49 -40
- package/internal/selection/tests/selection-specs.js +158 -253
- package/{build/internal → internal}/validators/validators.d.ts +0 -0
- package/internal/validators/validators.js +103 -55
- package/package.json +2 -2
- package/resolution/ResolutionDecorator.js +150 -97
- package/{build/resolution → resolution}/index.d.ts +0 -0
- package/resolution/index.js +39 -7
- package/resolution/resolution.js +232 -183
- package/resolution/tests/ResolutionDecorator-specs.js +42 -48
- package/resolution/tests/resolution-specs.js +90 -91
- package/useControlledState/tests/useControlledState-specs.js +100 -76
- package/{build/useControlledState → useControlledState}/useControlledState.d.ts +0 -0
- package/useControlledState/useControlledState.js +56 -38
- package/useScroll/ScrollAnimator.js +138 -112
- package/useScroll/Scrollbar.js +199 -175
- package/{build/useScroll → useScroll}/Scrollbar.module.css +0 -0
- package/useScroll/ScrollbarTrack.js +46 -28
- package/{build/useScroll → useScroll}/ScrollbarTrack.module.css +0 -0
- package/{build/useScroll → useScroll}/useScroll.d.ts +0 -0
- package/useScroll/useScroll.js +1714 -1627
- package/{build/useScroll → useScroll}/useScroll.module.css +0 -0
- package/useScroll/utilDOM.js +62 -55
- package/useScroll/utilEvent.js +33 -28
- package/BodyText/BodyText.module.less +0 -11
- package/Button/Button.module.less +0 -57
- package/FloatingLayer/Scrim.module.less +0 -8
- package/GridListImageItem/GridListImageItem.module.less +0 -33
- package/Heading/Heading.module.less +0 -20
- package/Icon/Icon.module.less +0 -38
- package/IconButton/IconButton.module.less +0 -18
- package/Image/Image.module.less +0 -21
- package/ImageItem/ImageItem.module.less +0 -29
- package/Item/Item.module.less +0 -14
- package/LabeledIcon/LabeledIcon.module.less +0 -45
- package/Layout/Layout.module.less +0 -84
- package/Marquee/Marquee.module.less +0 -49
- package/ProgressBar/ProgressBar.module.less +0 -114
- package/Scrollable/ScrollThumb.module.less +0 -46
- package/Scrollable/Scrollable.module.less +0 -42
- package/Scrollable/Scrollbar.module.less +0 -35
- package/Scroller/Scroller.module.less +0 -10
- package/Scroller/UiScroller.module.less +0 -10
- package/Slider/Slider.module.less +0 -20
- package/SlotItem/SlotItem.module.less +0 -19
- package/Spinner/Spinner.module.less +0 -52
- package/ToggleIcon/ToggleIcon.module.less +0 -14
- package/ToggleItem/ToggleItem.module.less +0 -9
- package/Transition/Transition.module.less +0 -179
- package/VirtualList/UiVirtualList.module.less +0 -31
- package/VirtualList/VirtualList.module.less +0 -39
- package/build/A11yDecorator/A11yDecorator.js +0 -129
- package/build/A11yDecorator/package.json +0 -3
- package/build/A11yDecorator/tests/A11yDecorator-specs.js +0 -90
- package/build/AnnounceDecorator/Announce.js +0 -172
- package/build/AnnounceDecorator/AnnounceDecorator.js +0 -121
- package/build/AnnounceDecorator/package.json +0 -3
- package/build/AnnounceDecorator/tests/Announce-specs.js +0 -29
- package/build/AnnounceDecorator/tests/AnnounceDecorator-specs.js +0 -34
- package/build/AnnounceDecorator/tests/useAnnounce-specs.js +0 -56
- package/build/AnnounceDecorator/useAnnounce.js +0 -61
- package/build/BodyText/BodyText.js +0 -139
- package/build/BodyText/package.json +0 -3
- package/build/BodyText/tests/BodyText-specs.js +0 -67
- package/build/Button/Button.js +0 -283
- package/build/Button/package.json +0 -3
- package/build/CHANGELOG.md +0 -1089
- package/build/Cancelable/Cancelable.js +0 -271
- package/build/Cancelable/cancelHandler.js +0 -79
- package/build/Cancelable/modalHandler.js +0 -68
- package/build/Cancelable/package.json +0 -3
- package/build/Cancelable/tests/Cancelable-specs.js +0 -289
- package/build/Changeable/Changeable.js +0 -172
- package/build/Changeable/package.json +0 -3
- package/build/Changeable/tests/Changeable-specs.js +0 -262
- package/build/ComponentOverride/ComponentOverride.js +0 -68
- package/build/ComponentOverride/package.json +0 -3
- package/build/FloatingLayer/FloatingLayer.js +0 -339
- package/build/FloatingLayer/FloatingLayerDecorator.js +0 -174
- package/build/FloatingLayer/Scrim.js +0 -199
- package/build/FloatingLayer/index.js +0 -49
- package/build/FloatingLayer/tests/FloatingLayer-specs.js +0 -29
- package/build/FloatingLayer/tests/Scrim-specs.js +0 -26
- package/build/FloatingLayer/useFloatingLayer.js +0 -53
- package/build/ForwardRef/ForwardRef.js +0 -68
- package/build/ForwardRef/package.json +0 -3
- package/build/GridListImageItem/GridListImageItem.js +0 -257
- package/build/GridListImageItem/package.json +0 -3
- package/build/Group/Group.js +0 -217
- package/build/Group/GroupItem.js +0 -109
- package/build/Group/package.json +0 -3
- package/build/Group/tests/Group-specs.js +0 -128
- package/build/Heading/Heading.js +0 -158
- package/build/Heading/package.json +0 -3
- package/build/Heading/tests/Heading-specs.js +0 -46
- package/build/Icon/Icon.js +0 -234
- package/build/Icon/package.json +0 -3
- package/build/Icon/tests/Icon-specs.js +0 -92
- package/build/IconButton/IconButton.js +0 -252
- package/build/IconButton/package.json +0 -3
- package/build/Image/Image.js +0 -219
- package/build/Image/package.json +0 -3
- package/build/Image/tests/Image-specs.js +0 -55
- package/build/ImageItem/ImageItem.js +0 -180
- package/build/ImageItem/package.json +0 -3
- package/build/ImageItem/tests/ImageItem-specs.js +0 -133
- package/build/Item/Item.js +0 -166
- package/build/Item/package.json +0 -3
- package/build/Item/tests/Item-specs.js +0 -77
- package/build/LabeledIcon/LabeledIcon.js +0 -287
- package/build/LabeledIcon/package.json +0 -3
- package/build/LabeledIcon/tests/LabeledIcon-specs.js +0 -49
- package/build/Layout/Cell.js +0 -215
- package/build/Layout/Layout.js +0 -316
- package/build/Layout/package.json +0 -3
- package/build/Layout/tests/Layout-specs.js +0 -102
- package/build/Marquee/MarqueeBase.js +0 -307
- package/build/Marquee/MarqueeController.js +0 -346
- package/build/Marquee/MarqueeDecorator.js +0 -1029
- package/build/Marquee/index.js +0 -65
- package/build/Marquee/package.json +0 -3
- package/build/Marquee/tests/Marquee-specs.js +0 -275
- package/build/Measurable/Measurable.js +0 -163
- package/build/Measurable/package.json +0 -3
- package/build/Media/Media.js +0 -389
- package/build/Media/package.json +0 -3
- package/build/Placeholder/PlaceholderControllerDecorator.js +0 -210
- package/build/Placeholder/PlaceholderDecorator.js +0 -171
- package/build/Placeholder/index.js +0 -37
- package/build/Placeholder/package.json +0 -3
- package/build/ProgressBar/ProgressBar.js +0 -200
- package/build/ProgressBar/package.json +0 -3
- package/build/ProgressBar/tests/ProgressBar-specs.js +0 -80
- package/build/README.md +0 -45
- package/build/RadioDecorator/RadioControllerDecorator.js +0 -117
- package/build/RadioDecorator/RadioDecorator.js +0 -199
- package/build/RadioDecorator/package.json +0 -3
- package/build/RadioDecorator/tests/RadioDecorator-specs.js +0 -155
- package/build/Repeater/Repeater.js +0 -190
- package/build/Repeater/package.json +0 -3
- package/build/Repeater/tests/Repeater-specs.js +0 -141
- package/build/Resizable/Resizable.js +0 -179
- package/build/Resizable/package.json +0 -3
- package/build/Routable/Link.js +0 -78
- package/build/Routable/Routable.js +0 -170
- package/build/Routable/Route.js +0 -68
- package/build/Routable/Router.js +0 -248
- package/build/Routable/package.json +0 -3
- package/build/Routable/tests/Router-specs.js +0 -200
- package/build/Routable/util.js +0 -90
- package/build/Scrollable/ScrollAnimator.js +0 -146
- package/build/Scrollable/ScrollThumb.js +0 -63
- package/build/Scrollable/Scrollable.js +0 -1612
- package/build/Scrollable/ScrollableNative.js +0 -1619
- package/build/Scrollable/Scrollbar.js +0 -344
- package/build/Scrollable/package.json +0 -3
- package/build/Scroller/Scroller.js +0 -291
- package/build/Scroller/ScrollerBasic.js +0 -322
- package/build/Scroller/UiScrollerBase.js +0 -414
- package/build/Scroller/package.json +0 -3
- package/build/Skinnable/Skinnable.js +0 -224
- package/build/Skinnable/package.json +0 -3
- package/build/Skinnable/tests/Skinnable-specs.js +0 -388
- package/build/Skinnable/tests/useSkins-specs.js +0 -290
- package/build/Skinnable/tests/util-specs.js +0 -120
- package/build/Skinnable/useSkins.js +0 -134
- package/build/Skinnable/util.js +0 -106
- package/build/Slider/Knob.js +0 -100
- package/build/Slider/PositionDecorator.js +0 -234
- package/build/Slider/Slider.js +0 -380
- package/build/Slider/package.json +0 -3
- package/build/Slider/utils.js +0 -18
- package/build/SlotItem/SlotItem.js +0 -245
- package/build/SlotItem/package.json +0 -3
- package/build/Slottable/Slottable.js +0 -95
- package/build/Slottable/package.json +0 -3
- package/build/Slottable/tests/Slottable-specs.js +0 -238
- package/build/Slottable/tests/useSlots-specs.js +0 -282
- package/build/Slottable/useSlots.js +0 -183
- package/build/Spinner/Spinner.js +0 -247
- package/build/Spinner/package.json +0 -3
- package/build/Spinner/tests/Spinner-specs.js +0 -61
- package/build/ToggleIcon/ToggleIcon.js +0 -181
- package/build/ToggleIcon/package.json +0 -3
- package/build/ToggleIcon/tests/ToggleIcon-specs.js +0 -58
- package/build/ToggleItem/ToggleItem.js +0 -306
- package/build/ToggleItem/package.json +0 -3
- package/build/ToggleItem/tests/ToggleItem-specs.js +0 -100
- package/build/Toggleable/Toggle.js +0 -74
- package/build/Toggleable/Toggleable.js +0 -250
- package/build/Toggleable/package.json +0 -3
- package/build/Toggleable/tests/Toggleable-specs.js +0 -421
- package/build/Toggleable/useToggle.js +0 -91
- package/build/Touchable/ClickAllow.js +0 -78
- package/build/Touchable/Drag.js +0 -206
- package/build/Touchable/Flick.js +0 -156
- package/build/Touchable/Hold.js +0 -262
- package/build/Touchable/Touchable.js +0 -661
- package/build/Touchable/config.js +0 -147
- package/build/Touchable/package.json +0 -3
- package/build/Touchable/state.js +0 -36
- package/build/Touchable/tests/Touchable-specs.js +0 -470
- package/build/Transition/Transition.js +0 -634
- package/build/Transition/package.json +0 -3
- package/build/Transition/tests/Transition-specs.js +0 -123
- package/build/ViewManager/Arranger.js +0 -181
- package/build/ViewManager/TransitionGroup.js +0 -547
- package/build/ViewManager/View.js +0 -403
- package/build/ViewManager/ViewManager.js +0 -386
- package/build/ViewManager/package.json +0 -3
- package/build/ViewManager/tests/View-specs.js +0 -182
- package/build/ViewManager/tests/ViewManager-specs.js +0 -524
- package/build/ViewManager/tests/test-utils.js +0 -47
- package/build/VirtualList/UiVirtualListBase.js +0 -1566
- package/build/VirtualList/VirtualList.js +0 -582
- package/build/VirtualList/VirtualListBase.js +0 -37
- package/build/VirtualList/VirtualListBasic.js +0 -1503
- package/build/VirtualList/package.json +0 -3
- package/build/VirtualList/tests/VirtualList-specs.js +0 -314
- package/build/index.js +0 -2
- package/build/internal/IdProvider/IdProvider.js +0 -99
- package/build/internal/IdProvider/Provider.js +0 -67
- package/build/internal/IdProvider/package.json +0 -3
- package/build/internal/IdProvider/tests/useId-specs.js +0 -64
- package/build/internal/IdProvider/useId.js +0 -58
- package/build/internal/Pure/Pure.js +0 -133
- package/build/internal/Pure/package.json +0 -3
- package/build/internal/localized-fonts/localized-fonts.js +0 -272
- package/build/internal/localized-fonts/package.json +0 -3
- package/build/internal/selection/package.json +0 -3
- package/build/internal/selection/selection.js +0 -78
- package/build/internal/selection/tests/selection-specs.js +0 -158
- package/build/internal/validators/package.json +0 -4
- package/build/internal/validators/validators.js +0 -163
- package/build/package-lock.json +0 -234
- package/build/package.json +0 -39
- package/build/resolution/ResolutionDecorator.js +0 -183
- package/build/resolution/index.js +0 -47
- package/build/resolution/package.json +0 -3
- package/build/resolution/resolution.js +0 -529
- package/build/resolution/tests/ResolutionDecorator-specs.js +0 -42
- package/build/resolution/tests/resolution-specs.js +0 -90
- package/build/styles/core.less +0 -91
- package/build/styles/mixins.less +0 -444
- package/build/styles/variables.less +0 -7
- package/build/useControlledState/package.json +0 -3
- package/build/useControlledState/tests/useControlledState-specs.js +0 -100
- package/build/useControlledState/useControlledState.js +0 -68
- package/build/useScroll/ScrollAnimator.js +0 -146
- package/build/useScroll/Scrollbar.js +0 -238
- package/build/useScroll/ScrollbarTrack.js +0 -62
- package/build/useScroll/package.json +0 -3
- package/build/useScroll/useScroll.js +0 -1730
- package/build/useScroll/utilDOM.js +0 -65
- package/build/useScroll/utilEvent.js +0 -39
- package/useScroll/Scrollbar.module.less +0 -37
- package/useScroll/ScrollbarTrack.module.less +0 -48
- package/useScroll/useScroll.module.less +0 -44
|
@@ -1,534 +1,470 @@
|
|
|
1
|
-
|
|
2
|
-
/* eslint-disable react/jsx-no-bind */
|
|
3
|
-
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import {shallow, mount} from 'enzyme';
|
|
6
|
-
|
|
7
|
-
import Touchable from '../Touchable';
|
|
8
|
-
import {activate, deactivate} from '../state';
|
|
9
|
-
import {configure, getConfig, resetDefaultConfig} from '../config';
|
|
10
|
-
|
|
11
|
-
describe('Touchable', () => {
|
|
12
|
-
|
|
13
|
-
const DivComponent = ({children = 'Toggle', id, onClick, onMouseDown, onMouseLeave, onMouseUp, onTouchStart, onTouchEnd}) => {
|
|
14
|
-
return (
|
|
15
|
-
<div
|
|
16
|
-
id={id}
|
|
17
|
-
onClick={onClick}
|
|
18
|
-
onMouseDown={onMouseDown}
|
|
19
|
-
onMouseUp={onMouseUp}
|
|
20
|
-
onMouseLeave={onMouseLeave}
|
|
21
|
-
onTouchStart={onTouchStart}
|
|
22
|
-
onTouchEnd={onTouchEnd}
|
|
23
|
-
>
|
|
24
|
-
{children}
|
|
25
|
-
</div>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
const preventDefault = (ev) => ev.preventDefault();
|
|
29
|
-
|
|
30
|
-
describe('config', () => {
|
|
31
|
-
|
|
32
|
-
beforeEach(resetDefaultConfig);
|
|
33
|
-
afterEach(resetDefaultConfig);
|
|
34
|
-
|
|
35
|
-
test(
|
|
36
|
-
'should pass active state to the wrapped component when activeProp is configured',
|
|
37
|
-
() => {
|
|
38
|
-
const Component = Touchable({activeProp: 'pressed'}, DivComponent);
|
|
39
|
-
const subject = shallow(
|
|
40
|
-
<Component />
|
|
41
|
-
);
|
|
42
|
-
const wrapped = subject.find(DivComponent);
|
|
43
|
-
|
|
44
|
-
const expected = true;
|
|
45
|
-
const actual = 'pressed' in wrapped.props();
|
|
46
|
-
|
|
47
|
-
expect(actual).toBe(expected);
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
test(
|
|
52
|
-
'should update state configurations onHoldPulse events',
|
|
53
|
-
(done) => {
|
|
54
|
-
const holdConfig = {
|
|
55
|
-
events: [
|
|
56
|
-
{name: 'hold', time: 10}
|
|
57
|
-
],
|
|
58
|
-
frequency: 10
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const Component = Touchable(DivComponent);
|
|
62
|
-
const handler = jest.fn();
|
|
63
|
-
const subject = mount(
|
|
64
|
-
<Component onHold={() => {}} holdConfig={holdConfig} />
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const ev = {};
|
|
68
|
-
subject.simulate('mousedown', ev);
|
|
69
|
-
subject.setProps({
|
|
70
|
-
onHoldPulse: handler
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
setTimeout(() => {
|
|
74
|
-
expect(handler).toHaveBeenCalled();
|
|
75
|
-
done();
|
|
76
|
-
}, 20);
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
test(
|
|
81
|
-
'should update state configurations onHold events',
|
|
82
|
-
(done) => {
|
|
83
|
-
const holdConfig = {
|
|
84
|
-
events: [
|
|
85
|
-
{name: 'hold', time: 10}
|
|
86
|
-
],
|
|
87
|
-
frequency: 10
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const Component = Touchable(DivComponent);
|
|
91
|
-
const handler = jest.fn();
|
|
92
|
-
const subject = mount(
|
|
93
|
-
<Component onHoldPulse={() => {}} holdConfig={holdConfig} />
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const ev = {};
|
|
97
|
-
subject.simulate('mousedown', ev);
|
|
98
|
-
subject.setProps({
|
|
99
|
-
onHold: handler
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
setTimeout(() => {
|
|
103
|
-
expect(handler).toHaveBeenCalled();
|
|
104
|
-
done();
|
|
105
|
-
}, 20);
|
|
106
|
-
}
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
test(
|
|
110
|
-
'should update state configurations onHoldEnd events',
|
|
111
|
-
(done) => {
|
|
112
|
-
const holdConfig = {
|
|
113
|
-
events: [
|
|
114
|
-
{name: 'hold', time: 10}
|
|
115
|
-
],
|
|
116
|
-
frequency: 10
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const Component = Touchable(DivComponent);
|
|
120
|
-
const handler = jest.fn();
|
|
121
|
-
const subject = mount(
|
|
122
|
-
<Component onHoldPulse={() => {}} holdConfig={holdConfig} />
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
const ev = {currentTarget: {}};
|
|
126
|
-
subject.simulate('mousedown', ev);
|
|
127
|
-
subject.setProps({
|
|
128
|
-
onHoldEnd: handler
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
setTimeout(() => {
|
|
132
|
-
subject.simulate('mouseup', ev);
|
|
133
|
-
expect(handler).toHaveBeenCalled();
|
|
134
|
-
done();
|
|
135
|
-
}, 30);
|
|
136
|
-
}
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
test('should merge configurations', () => {
|
|
140
|
-
configure({
|
|
141
|
-
flick: {
|
|
142
|
-
maxMoves: 10
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
const expected = 10;
|
|
147
|
-
const actual = getConfig().flick.maxMoves;
|
|
148
|
-
|
|
149
|
-
expect(actual).toBe(expected);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
test('should omit unsupported configurations', () => {
|
|
153
|
-
configure({
|
|
154
|
-
flick: {
|
|
155
|
-
notSupported: 10
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
// eslint-disable-next-line no-undefined
|
|
160
|
-
const expected = undefined;
|
|
161
|
-
const actual = getConfig().flick.notSupported;
|
|
162
|
-
|
|
163
|
-
expect(actual).toBe(expected);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
test('should not update config when local object is mutated', () => {
|
|
167
|
-
const cfg = {
|
|
168
|
-
flick: {
|
|
169
|
-
maxMoves: 10
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
configure(cfg);
|
|
174
|
-
cfg.flick.maxMoves = 20;
|
|
175
|
-
|
|
176
|
-
const expected = 10;
|
|
177
|
-
const actual = getConfig().flick.maxMoves;
|
|
178
|
-
|
|
179
|
-
expect(actual).toBe(expected);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
test(
|
|
183
|
-
'should not update config when local hold.events array is mutated',
|
|
184
|
-
() => {
|
|
185
|
-
const cfg = {
|
|
186
|
-
hold: {
|
|
187
|
-
events: [
|
|
188
|
-
{name: 'hold', time: 600}
|
|
189
|
-
]
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
configure(cfg);
|
|
194
|
-
cfg.hold.events[0].time = 2000;
|
|
195
|
-
|
|
196
|
-
const expected = 600;
|
|
197
|
-
const actual = getConfig().hold.events[0].time;
|
|
198
|
-
|
|
199
|
-
expect(actual).toBe(expected);
|
|
200
|
-
}
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
describe('#onDown', () => {
|
|
206
|
-
test('should invoke onDown handle on mouse down', () => {
|
|
207
|
-
const Component = Touchable(DivComponent);
|
|
208
|
-
const handler = jest.fn();
|
|
209
|
-
const subject = mount(
|
|
210
|
-
<Component onDown={handler} />
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
subject.simulate('mousedown', {});
|
|
214
|
-
|
|
215
|
-
const expected = 1;
|
|
216
|
-
const actual = handler.mock.calls.length;
|
|
217
|
-
|
|
218
|
-
expect(actual).toBe(expected);
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
describe('#onUp', () => {
|
|
223
|
-
test('should invoke onUp handle on mouse up', () => {
|
|
224
|
-
const Component = Touchable({activeProp: 'pressed'}, DivComponent);
|
|
225
|
-
const handler = jest.fn();
|
|
226
|
-
const subject = mount(
|
|
227
|
-
<Component onUp={handler} />
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
const ev = {};
|
|
231
|
-
subject.simulate('mousedown', ev);
|
|
232
|
-
subject.simulate('mouseup', ev);
|
|
233
|
-
|
|
234
|
-
const expected = 1;
|
|
235
|
-
const actual = handler.mock.calls.length;
|
|
236
|
-
|
|
237
|
-
expect(actual).toBe(expected);
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
describe('#onTap', () => {
|
|
242
|
-
test('should be called on mouse up', () => {
|
|
243
|
-
const Component = Touchable({activeProp: 'active'}, DivComponent);
|
|
244
|
-
const handler = jest.fn();
|
|
245
|
-
const subject = mount(
|
|
246
|
-
<Component onTap={handler} />
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
const ev = {};
|
|
250
|
-
subject.simulate('mousedown', ev);
|
|
251
|
-
subject.simulate('mouseup', ev);
|
|
252
|
-
|
|
253
|
-
const expected = 1;
|
|
254
|
-
const actual = handler.mock.calls.length;
|
|
255
|
-
|
|
256
|
-
expect(actual).toBe(expected);
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
test('should be called on click', () => {
|
|
260
|
-
const Component = Touchable({activeProp: 'active'}, DivComponent);
|
|
261
|
-
const handler = jest.fn();
|
|
262
|
-
const subject = mount(
|
|
263
|
-
<Component onTap={handler} />
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
subject.simulate('click');
|
|
1
|
+
"use strict";
|
|
267
2
|
|
|
268
|
-
|
|
269
|
-
const actual = handler.mock.calls.length;
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
270
4
|
|
|
271
|
-
|
|
272
|
-
});
|
|
5
|
+
var _enzyme = require("enzyme");
|
|
273
6
|
|
|
274
|
-
|
|
275
|
-
const Component = Touchable({activeProp: 'active'}, DivComponent);
|
|
276
|
-
const handler = jest.fn();
|
|
277
|
-
const subject = mount(
|
|
278
|
-
<Component onTap={handler} onClick={handler} />
|
|
279
|
-
);
|
|
7
|
+
var _Touchable = _interopRequireDefault(require("../Touchable"));
|
|
280
8
|
|
|
281
|
-
|
|
9
|
+
var _state = require("../state");
|
|
282
10
|
|
|
283
|
-
|
|
284
|
-
const actual = handler.mock.calls.map(call => call[0].type);
|
|
11
|
+
var _config = require("../config");
|
|
285
12
|
|
|
286
|
-
|
|
287
|
-
});
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
288
14
|
|
|
289
|
-
|
|
290
|
-
const Component = Touchable({activeProp: 'active'}, DivComponent);
|
|
291
|
-
const handler = jest.fn();
|
|
292
|
-
const subject = mount(
|
|
293
|
-
<Component onTap={handler} onClick={handler} />
|
|
294
|
-
);
|
|
295
|
-
|
|
296
|
-
const ev = {
|
|
297
|
-
// a matching timeStamp is used by Touchable to prevent multiple onTaps on "true"
|
|
298
|
-
// click (mouseup + click)
|
|
299
|
-
timeStamp: 1
|
|
300
|
-
};
|
|
301
|
-
subject.simulate('mousedown', ev);
|
|
302
|
-
subject.simulate('mouseup', ev);
|
|
303
|
-
subject.simulate('click', ev);
|
|
304
|
-
|
|
305
|
-
const expected = ['onTap', 'click'];
|
|
306
|
-
const actual = handler.mock.calls.map(call => call[0].type);
|
|
307
|
-
|
|
308
|
-
expect(actual).toEqual(expected);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
test('should be preventable via onUp handler', () => {
|
|
312
|
-
const Component = Touchable({activeProp: 'active'}, DivComponent);
|
|
313
|
-
const handler = jest.fn();
|
|
314
|
-
const subject = mount(
|
|
315
|
-
<Component onTap={handler} onUp={preventDefault} />
|
|
316
|
-
);
|
|
317
|
-
|
|
318
|
-
const ev = {};
|
|
319
|
-
subject.simulate('mousedown', ev);
|
|
320
|
-
subject.simulate('mouseup', ev);
|
|
321
|
-
|
|
322
|
-
const expected = 0;
|
|
323
|
-
const actual = handler.mock.calls.length;
|
|
324
|
-
|
|
325
|
-
expect(actual).toBe(expected);
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
describe('state management', () => {
|
|
330
|
-
describe('activate', () => {
|
|
331
|
-
test('should return null when active', () => {
|
|
332
|
-
const state = {
|
|
333
|
-
active: 2
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
const expected = null;
|
|
337
|
-
const actual = activate(state);
|
|
338
|
-
|
|
339
|
-
expect(actual).toBe(expected);
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
test('should return updated state when inactive', () => {
|
|
343
|
-
const state = {
|
|
344
|
-
active: 0
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
const expected = {active: 2};
|
|
348
|
-
const actual = activate(state);
|
|
349
|
-
|
|
350
|
-
expect(actual).toEqual(expected);
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
test(
|
|
354
|
-
'should update active state on mouse down when activeProp is configured',
|
|
355
|
-
() => {
|
|
356
|
-
const Component = Touchable({activeProp: 'active'}, DivComponent);
|
|
357
|
-
const handler = jest.fn();
|
|
358
|
-
const subject = mount(
|
|
359
|
-
<Component onDown={handler} />
|
|
360
|
-
);
|
|
361
|
-
|
|
362
|
-
const ev = {};
|
|
363
|
-
const beforeDown = subject.state('active');
|
|
364
|
-
subject.simulate('mousedown', ev);
|
|
365
|
-
const afterDown = subject.state('active');
|
|
366
|
-
|
|
367
|
-
const expected = false;
|
|
368
|
-
const actual = beforeDown === afterDown;
|
|
369
|
-
|
|
370
|
-
expect(actual).toBe(expected);
|
|
371
|
-
}
|
|
372
|
-
);
|
|
373
|
-
|
|
374
|
-
test(
|
|
375
|
-
'should not update active state on mouse down when disabled',
|
|
376
|
-
() => {
|
|
377
|
-
const Component = Touchable({activeProp: 'active'}, DivComponent);
|
|
378
|
-
const handler = jest.fn();
|
|
379
|
-
const subject = mount(
|
|
380
|
-
<Component onDown={handler} disabled />
|
|
381
|
-
);
|
|
382
|
-
|
|
383
|
-
subject.simulate('mousedown', {});
|
|
384
|
-
|
|
385
|
-
const expected = 0;
|
|
386
|
-
const actual = subject.state('active');
|
|
387
|
-
|
|
388
|
-
expect(actual).toBe(expected);
|
|
389
|
-
}
|
|
390
|
-
);
|
|
391
|
-
|
|
392
|
-
test(
|
|
393
|
-
'should not update active state on mouse down when preventDefault is called',
|
|
394
|
-
() => {
|
|
395
|
-
const Component = Touchable({activeProp: 'active'}, DivComponent);
|
|
396
|
-
const handler = (ev) => ev.preventDefault();
|
|
397
|
-
const subject = mount(
|
|
398
|
-
<Component onDown={handler} />
|
|
399
|
-
);
|
|
400
|
-
|
|
401
|
-
subject.simulate('mousedown', {});
|
|
402
|
-
|
|
403
|
-
const expected = 0;
|
|
404
|
-
const actual = subject.state('active');
|
|
405
|
-
|
|
406
|
-
expect(actual).toBe(expected);
|
|
407
|
-
}
|
|
408
|
-
);
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
describe('deactivate', () => {
|
|
412
|
-
test('should return null when inactive', () => {
|
|
413
|
-
const state = {
|
|
414
|
-
active: 0
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
const expected = null;
|
|
418
|
-
const actual = deactivate(state);
|
|
419
|
-
|
|
420
|
-
expect(actual).toBe(expected);
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
test('should return updated state when active', () => {
|
|
424
|
-
const state = {
|
|
425
|
-
active: 2
|
|
426
|
-
};
|
|
427
|
-
|
|
428
|
-
const expected = {active: 0};
|
|
429
|
-
const actual = deactivate(state);
|
|
430
|
-
|
|
431
|
-
expect(actual).toEqual(expected);
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
test(
|
|
435
|
-
'should update active state on mouse up when activeProp is configured',
|
|
436
|
-
() => {
|
|
437
|
-
const Component = Touchable({activeProp: 'active'}, DivComponent);
|
|
438
|
-
const handler = jest.fn();
|
|
439
|
-
const subject = mount(
|
|
440
|
-
<Component onDown={handler} />
|
|
441
|
-
);
|
|
442
|
-
|
|
443
|
-
const ev = {};
|
|
444
|
-
subject.simulate('mousedown', ev);
|
|
445
|
-
|
|
446
|
-
const beforeUp = subject.state('active');
|
|
447
|
-
subject.simulate('mouseup', ev);
|
|
448
|
-
const afterUp = subject.state('active');
|
|
449
|
-
|
|
450
|
-
const expected = false;
|
|
451
|
-
const actual = beforeUp === afterUp;
|
|
452
|
-
|
|
453
|
-
expect(actual).toBe(expected);
|
|
454
|
-
}
|
|
455
|
-
);
|
|
456
|
-
|
|
457
|
-
test(
|
|
458
|
-
'should not update active state on mouse down when disabled',
|
|
459
|
-
() => {
|
|
460
|
-
const Component = Touchable({activeProp: 'active'}, DivComponent);
|
|
461
|
-
const handler = jest.fn();
|
|
462
|
-
const subject = mount(
|
|
463
|
-
<Component onDown={handler} disabled />
|
|
464
|
-
);
|
|
465
|
-
|
|
466
|
-
const ev = {};
|
|
467
|
-
subject.simulate('mousedown', ev);
|
|
468
|
-
|
|
469
|
-
const beforeUp = subject.state('active');
|
|
470
|
-
subject.simulate('mouseup', ev);
|
|
471
|
-
const afterUp = subject.state('active');
|
|
472
|
-
|
|
473
|
-
const expected = true;
|
|
474
|
-
const actual = beforeUp === afterUp;
|
|
475
|
-
|
|
476
|
-
expect(actual).toBe(expected);
|
|
477
|
-
}
|
|
478
|
-
);
|
|
479
|
-
|
|
480
|
-
test(
|
|
481
|
-
'should not update active state on mouse down when preventDefault is called',
|
|
482
|
-
() => {
|
|
483
|
-
const Component = Touchable({activeProp: 'active'}, DivComponent);
|
|
484
|
-
const subject = mount(
|
|
485
|
-
<Component onDown={preventDefault} />
|
|
486
|
-
);
|
|
487
|
-
|
|
488
|
-
const ev = {};
|
|
489
|
-
subject.simulate('mousedown', ev);
|
|
490
|
-
|
|
491
|
-
const beforeUp = subject.state('active');
|
|
492
|
-
subject.simulate('mouseup', ev);
|
|
493
|
-
const afterUp = subject.state('active');
|
|
494
|
-
|
|
495
|
-
const expected = true;
|
|
496
|
-
const actual = beforeUp === afterUp;
|
|
497
|
-
|
|
498
|
-
expect(actual).toBe(expected);
|
|
499
|
-
}
|
|
500
|
-
);
|
|
501
|
-
});
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
describe('touch', () => {
|
|
505
|
-
test('should only emit onTap once when tapping an child instance of Touchable', () => {
|
|
506
|
-
const Component = Touchable(DivComponent);
|
|
507
|
-
const handler = jest.fn();
|
|
508
|
-
const subject = mount(
|
|
509
|
-
<Component onTap={handler} id="outer">
|
|
510
|
-
<Component id="inner" />
|
|
511
|
-
</Component>
|
|
512
|
-
);
|
|
513
|
-
|
|
514
|
-
const mouseEvent = {
|
|
515
|
-
timeStamp: 1
|
|
516
|
-
};
|
|
517
|
-
const touchEvent = {
|
|
518
|
-
timeStamp: 1,
|
|
519
|
-
changedTouches: [{clientX: 0, clientY: 0}],
|
|
520
|
-
targetTouches: [{clientX: 0, clientY: 0}]
|
|
521
|
-
};
|
|
522
|
-
const inner = subject.find('div#inner');
|
|
523
|
-
inner.simulate('touchstart', touchEvent);
|
|
524
|
-
inner.simulate('touchend', touchEvent);
|
|
525
|
-
inner.simulate('mousedown', mouseEvent);
|
|
526
|
-
inner.simulate('mouseup', mouseEvent);
|
|
527
|
-
|
|
528
|
-
const expected = 1;
|
|
529
|
-
const actual = handler.mock.calls.length;
|
|
15
|
+
/* eslint-disable enact/prop-types */
|
|
530
16
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
17
|
+
/* eslint-disable react/jsx-no-bind */
|
|
18
|
+
describe('Touchable', function () {
|
|
19
|
+
var DivComponent = function DivComponent(_ref) {
|
|
20
|
+
var _ref$children = _ref.children,
|
|
21
|
+
children = _ref$children === void 0 ? 'Toggle' : _ref$children,
|
|
22
|
+
id = _ref.id,
|
|
23
|
+
onClick = _ref.onClick,
|
|
24
|
+
onMouseDown = _ref.onMouseDown,
|
|
25
|
+
onMouseLeave = _ref.onMouseLeave,
|
|
26
|
+
onMouseUp = _ref.onMouseUp,
|
|
27
|
+
onTouchStart = _ref.onTouchStart,
|
|
28
|
+
onTouchEnd = _ref.onTouchEnd;
|
|
29
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
30
|
+
id: id,
|
|
31
|
+
onClick: onClick,
|
|
32
|
+
onMouseDown: onMouseDown,
|
|
33
|
+
onMouseUp: onMouseUp,
|
|
34
|
+
onMouseLeave: onMouseLeave,
|
|
35
|
+
onTouchStart: onTouchStart,
|
|
36
|
+
onTouchEnd: onTouchEnd
|
|
37
|
+
}, children);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var preventDefault = function preventDefault(ev) {
|
|
41
|
+
return ev.preventDefault();
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
describe('config', function () {
|
|
45
|
+
beforeEach(_config.resetDefaultConfig);
|
|
46
|
+
afterEach(_config.resetDefaultConfig);
|
|
47
|
+
test('should pass active state to the wrapped component when activeProp is configured', function () {
|
|
48
|
+
var Component = (0, _Touchable["default"])({
|
|
49
|
+
activeProp: 'pressed'
|
|
50
|
+
}, DivComponent);
|
|
51
|
+
var subject = (0, _enzyme.shallow)( /*#__PURE__*/_react["default"].createElement(Component, null));
|
|
52
|
+
var wrapped = subject.find(DivComponent);
|
|
53
|
+
var expected = true;
|
|
54
|
+
var actual = ('pressed' in wrapped.props());
|
|
55
|
+
expect(actual).toBe(expected);
|
|
56
|
+
});
|
|
57
|
+
test('should update state configurations onHoldPulse events', function (done) {
|
|
58
|
+
var holdConfig = {
|
|
59
|
+
events: [{
|
|
60
|
+
name: 'hold',
|
|
61
|
+
time: 10
|
|
62
|
+
}],
|
|
63
|
+
frequency: 10
|
|
64
|
+
};
|
|
65
|
+
var Component = (0, _Touchable["default"])(DivComponent);
|
|
66
|
+
var handler = jest.fn();
|
|
67
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
68
|
+
onHold: function onHold() {},
|
|
69
|
+
holdConfig: holdConfig
|
|
70
|
+
}));
|
|
71
|
+
var ev = {};
|
|
72
|
+
subject.simulate('mousedown', ev);
|
|
73
|
+
subject.setProps({
|
|
74
|
+
onHoldPulse: handler
|
|
75
|
+
});
|
|
76
|
+
setTimeout(function () {
|
|
77
|
+
expect(handler).toHaveBeenCalled();
|
|
78
|
+
done();
|
|
79
|
+
}, 20);
|
|
80
|
+
});
|
|
81
|
+
test('should update state configurations onHold events', function (done) {
|
|
82
|
+
var holdConfig = {
|
|
83
|
+
events: [{
|
|
84
|
+
name: 'hold',
|
|
85
|
+
time: 10
|
|
86
|
+
}],
|
|
87
|
+
frequency: 10
|
|
88
|
+
};
|
|
89
|
+
var Component = (0, _Touchable["default"])(DivComponent);
|
|
90
|
+
var handler = jest.fn();
|
|
91
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
92
|
+
onHoldPulse: function onHoldPulse() {},
|
|
93
|
+
holdConfig: holdConfig
|
|
94
|
+
}));
|
|
95
|
+
var ev = {};
|
|
96
|
+
subject.simulate('mousedown', ev);
|
|
97
|
+
subject.setProps({
|
|
98
|
+
onHold: handler
|
|
99
|
+
});
|
|
100
|
+
setTimeout(function () {
|
|
101
|
+
expect(handler).toHaveBeenCalled();
|
|
102
|
+
done();
|
|
103
|
+
}, 20);
|
|
104
|
+
});
|
|
105
|
+
test('should update state configurations onHoldEnd events', function (done) {
|
|
106
|
+
var holdConfig = {
|
|
107
|
+
events: [{
|
|
108
|
+
name: 'hold',
|
|
109
|
+
time: 10
|
|
110
|
+
}],
|
|
111
|
+
frequency: 10
|
|
112
|
+
};
|
|
113
|
+
var Component = (0, _Touchable["default"])(DivComponent);
|
|
114
|
+
var handler = jest.fn();
|
|
115
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
116
|
+
onHoldPulse: function onHoldPulse() {},
|
|
117
|
+
holdConfig: holdConfig
|
|
118
|
+
}));
|
|
119
|
+
var ev = {
|
|
120
|
+
currentTarget: {}
|
|
121
|
+
};
|
|
122
|
+
subject.simulate('mousedown', ev);
|
|
123
|
+
subject.setProps({
|
|
124
|
+
onHoldEnd: handler
|
|
125
|
+
});
|
|
126
|
+
setTimeout(function () {
|
|
127
|
+
subject.simulate('mouseup', ev);
|
|
128
|
+
expect(handler).toHaveBeenCalled();
|
|
129
|
+
done();
|
|
130
|
+
}, 30);
|
|
131
|
+
});
|
|
132
|
+
test('should merge configurations', function () {
|
|
133
|
+
(0, _config.configure)({
|
|
134
|
+
flick: {
|
|
135
|
+
maxMoves: 10
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
var expected = 10;
|
|
139
|
+
var actual = (0, _config.getConfig)().flick.maxMoves;
|
|
140
|
+
expect(actual).toBe(expected);
|
|
141
|
+
});
|
|
142
|
+
test('should omit unsupported configurations', function () {
|
|
143
|
+
(0, _config.configure)({
|
|
144
|
+
flick: {
|
|
145
|
+
notSupported: 10
|
|
146
|
+
}
|
|
147
|
+
}); // eslint-disable-next-line no-undefined
|
|
148
|
+
|
|
149
|
+
var expected = undefined;
|
|
150
|
+
var actual = (0, _config.getConfig)().flick.notSupported;
|
|
151
|
+
expect(actual).toBe(expected);
|
|
152
|
+
});
|
|
153
|
+
test('should not update config when local object is mutated', function () {
|
|
154
|
+
var cfg = {
|
|
155
|
+
flick: {
|
|
156
|
+
maxMoves: 10
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
(0, _config.configure)(cfg);
|
|
160
|
+
cfg.flick.maxMoves = 20;
|
|
161
|
+
var expected = 10;
|
|
162
|
+
var actual = (0, _config.getConfig)().flick.maxMoves;
|
|
163
|
+
expect(actual).toBe(expected);
|
|
164
|
+
});
|
|
165
|
+
test('should not update config when local hold.events array is mutated', function () {
|
|
166
|
+
var cfg = {
|
|
167
|
+
hold: {
|
|
168
|
+
events: [{
|
|
169
|
+
name: 'hold',
|
|
170
|
+
time: 600
|
|
171
|
+
}]
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
(0, _config.configure)(cfg);
|
|
175
|
+
cfg.hold.events[0].time = 2000;
|
|
176
|
+
var expected = 600;
|
|
177
|
+
var actual = (0, _config.getConfig)().hold.events[0].time;
|
|
178
|
+
expect(actual).toBe(expected);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
describe('#onDown', function () {
|
|
182
|
+
test('should invoke onDown handle on mouse down', function () {
|
|
183
|
+
var Component = (0, _Touchable["default"])(DivComponent);
|
|
184
|
+
var handler = jest.fn();
|
|
185
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
186
|
+
onDown: handler
|
|
187
|
+
}));
|
|
188
|
+
subject.simulate('mousedown', {});
|
|
189
|
+
var expected = 1;
|
|
190
|
+
var actual = handler.mock.calls.length;
|
|
191
|
+
expect(actual).toBe(expected);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
describe('#onUp', function () {
|
|
195
|
+
test('should invoke onUp handle on mouse up', function () {
|
|
196
|
+
var Component = (0, _Touchable["default"])({
|
|
197
|
+
activeProp: 'pressed'
|
|
198
|
+
}, DivComponent);
|
|
199
|
+
var handler = jest.fn();
|
|
200
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
201
|
+
onUp: handler
|
|
202
|
+
}));
|
|
203
|
+
var ev = {};
|
|
204
|
+
subject.simulate('mousedown', ev);
|
|
205
|
+
subject.simulate('mouseup', ev);
|
|
206
|
+
var expected = 1;
|
|
207
|
+
var actual = handler.mock.calls.length;
|
|
208
|
+
expect(actual).toBe(expected);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
describe('#onTap', function () {
|
|
212
|
+
test('should be called on mouse up', function () {
|
|
213
|
+
var Component = (0, _Touchable["default"])({
|
|
214
|
+
activeProp: 'active'
|
|
215
|
+
}, DivComponent);
|
|
216
|
+
var handler = jest.fn();
|
|
217
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
218
|
+
onTap: handler
|
|
219
|
+
}));
|
|
220
|
+
var ev = {};
|
|
221
|
+
subject.simulate('mousedown', ev);
|
|
222
|
+
subject.simulate('mouseup', ev);
|
|
223
|
+
var expected = 1;
|
|
224
|
+
var actual = handler.mock.calls.length;
|
|
225
|
+
expect(actual).toBe(expected);
|
|
226
|
+
});
|
|
227
|
+
test('should be called on click', function () {
|
|
228
|
+
var Component = (0, _Touchable["default"])({
|
|
229
|
+
activeProp: 'active'
|
|
230
|
+
}, DivComponent);
|
|
231
|
+
var handler = jest.fn();
|
|
232
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
233
|
+
onTap: handler
|
|
234
|
+
}));
|
|
235
|
+
subject.simulate('click');
|
|
236
|
+
var expected = 1;
|
|
237
|
+
var actual = handler.mock.calls.length;
|
|
238
|
+
expect(actual).toBe(expected);
|
|
239
|
+
});
|
|
240
|
+
test('should be called before onClick on click', function () {
|
|
241
|
+
var Component = (0, _Touchable["default"])({
|
|
242
|
+
activeProp: 'active'
|
|
243
|
+
}, DivComponent);
|
|
244
|
+
var handler = jest.fn();
|
|
245
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
246
|
+
onTap: handler,
|
|
247
|
+
onClick: handler
|
|
248
|
+
}));
|
|
249
|
+
subject.simulate('click');
|
|
250
|
+
var expected = ['onTap', 'click'];
|
|
251
|
+
var actual = handler.mock.calls.map(function (call) {
|
|
252
|
+
return call[0].type;
|
|
253
|
+
});
|
|
254
|
+
expect(actual).toEqual(expected);
|
|
255
|
+
});
|
|
256
|
+
test('should be called before onCLick on mouse up', function () {
|
|
257
|
+
var Component = (0, _Touchable["default"])({
|
|
258
|
+
activeProp: 'active'
|
|
259
|
+
}, DivComponent);
|
|
260
|
+
var handler = jest.fn();
|
|
261
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
262
|
+
onTap: handler,
|
|
263
|
+
onClick: handler
|
|
264
|
+
}));
|
|
265
|
+
var ev = {
|
|
266
|
+
// a matching timeStamp is used by Touchable to prevent multiple onTaps on "true"
|
|
267
|
+
// click (mouseup + click)
|
|
268
|
+
timeStamp: 1
|
|
269
|
+
};
|
|
270
|
+
subject.simulate('mousedown', ev);
|
|
271
|
+
subject.simulate('mouseup', ev);
|
|
272
|
+
subject.simulate('click', ev);
|
|
273
|
+
var expected = ['onTap', 'click'];
|
|
274
|
+
var actual = handler.mock.calls.map(function (call) {
|
|
275
|
+
return call[0].type;
|
|
276
|
+
});
|
|
277
|
+
expect(actual).toEqual(expected);
|
|
278
|
+
});
|
|
279
|
+
test('should be preventable via onUp handler', function () {
|
|
280
|
+
var Component = (0, _Touchable["default"])({
|
|
281
|
+
activeProp: 'active'
|
|
282
|
+
}, DivComponent);
|
|
283
|
+
var handler = jest.fn();
|
|
284
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
285
|
+
onTap: handler,
|
|
286
|
+
onUp: preventDefault
|
|
287
|
+
}));
|
|
288
|
+
var ev = {};
|
|
289
|
+
subject.simulate('mousedown', ev);
|
|
290
|
+
subject.simulate('mouseup', ev);
|
|
291
|
+
var expected = 0;
|
|
292
|
+
var actual = handler.mock.calls.length;
|
|
293
|
+
expect(actual).toBe(expected);
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
describe('state management', function () {
|
|
297
|
+
describe('activate', function () {
|
|
298
|
+
test('should return null when active', function () {
|
|
299
|
+
var state = {
|
|
300
|
+
active: 2
|
|
301
|
+
};
|
|
302
|
+
var expected = null;
|
|
303
|
+
var actual = (0, _state.activate)(state);
|
|
304
|
+
expect(actual).toBe(expected);
|
|
305
|
+
});
|
|
306
|
+
test('should return updated state when inactive', function () {
|
|
307
|
+
var state = {
|
|
308
|
+
active: 0
|
|
309
|
+
};
|
|
310
|
+
var expected = {
|
|
311
|
+
active: 2
|
|
312
|
+
};
|
|
313
|
+
var actual = (0, _state.activate)(state);
|
|
314
|
+
expect(actual).toEqual(expected);
|
|
315
|
+
});
|
|
316
|
+
test('should update active state on mouse down when activeProp is configured', function () {
|
|
317
|
+
var Component = (0, _Touchable["default"])({
|
|
318
|
+
activeProp: 'active'
|
|
319
|
+
}, DivComponent);
|
|
320
|
+
var handler = jest.fn();
|
|
321
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
322
|
+
onDown: handler
|
|
323
|
+
}));
|
|
324
|
+
var ev = {};
|
|
325
|
+
var beforeDown = subject.state('active');
|
|
326
|
+
subject.simulate('mousedown', ev);
|
|
327
|
+
var afterDown = subject.state('active');
|
|
328
|
+
var expected = false;
|
|
329
|
+
var actual = beforeDown === afterDown;
|
|
330
|
+
expect(actual).toBe(expected);
|
|
331
|
+
});
|
|
332
|
+
test('should not update active state on mouse down when disabled', function () {
|
|
333
|
+
var Component = (0, _Touchable["default"])({
|
|
334
|
+
activeProp: 'active'
|
|
335
|
+
}, DivComponent);
|
|
336
|
+
var handler = jest.fn();
|
|
337
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
338
|
+
onDown: handler,
|
|
339
|
+
disabled: true
|
|
340
|
+
}));
|
|
341
|
+
subject.simulate('mousedown', {});
|
|
342
|
+
var expected = 0;
|
|
343
|
+
var actual = subject.state('active');
|
|
344
|
+
expect(actual).toBe(expected);
|
|
345
|
+
});
|
|
346
|
+
test('should not update active state on mouse down when preventDefault is called', function () {
|
|
347
|
+
var Component = (0, _Touchable["default"])({
|
|
348
|
+
activeProp: 'active'
|
|
349
|
+
}, DivComponent);
|
|
350
|
+
|
|
351
|
+
var handler = function handler(ev) {
|
|
352
|
+
return ev.preventDefault();
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
356
|
+
onDown: handler
|
|
357
|
+
}));
|
|
358
|
+
subject.simulate('mousedown', {});
|
|
359
|
+
var expected = 0;
|
|
360
|
+
var actual = subject.state('active');
|
|
361
|
+
expect(actual).toBe(expected);
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
describe('deactivate', function () {
|
|
365
|
+
test('should return null when inactive', function () {
|
|
366
|
+
var state = {
|
|
367
|
+
active: 0
|
|
368
|
+
};
|
|
369
|
+
var expected = null;
|
|
370
|
+
var actual = (0, _state.deactivate)(state);
|
|
371
|
+
expect(actual).toBe(expected);
|
|
372
|
+
});
|
|
373
|
+
test('should return updated state when active', function () {
|
|
374
|
+
var state = {
|
|
375
|
+
active: 2
|
|
376
|
+
};
|
|
377
|
+
var expected = {
|
|
378
|
+
active: 0
|
|
379
|
+
};
|
|
380
|
+
var actual = (0, _state.deactivate)(state);
|
|
381
|
+
expect(actual).toEqual(expected);
|
|
382
|
+
});
|
|
383
|
+
test('should update active state on mouse up when activeProp is configured', function () {
|
|
384
|
+
var Component = (0, _Touchable["default"])({
|
|
385
|
+
activeProp: 'active'
|
|
386
|
+
}, DivComponent);
|
|
387
|
+
var handler = jest.fn();
|
|
388
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
389
|
+
onDown: handler
|
|
390
|
+
}));
|
|
391
|
+
var ev = {};
|
|
392
|
+
subject.simulate('mousedown', ev);
|
|
393
|
+
var beforeUp = subject.state('active');
|
|
394
|
+
subject.simulate('mouseup', ev);
|
|
395
|
+
var afterUp = subject.state('active');
|
|
396
|
+
var expected = false;
|
|
397
|
+
var actual = beforeUp === afterUp;
|
|
398
|
+
expect(actual).toBe(expected);
|
|
399
|
+
});
|
|
400
|
+
test('should not update active state on mouse down when disabled', function () {
|
|
401
|
+
var Component = (0, _Touchable["default"])({
|
|
402
|
+
activeProp: 'active'
|
|
403
|
+
}, DivComponent);
|
|
404
|
+
var handler = jest.fn();
|
|
405
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
406
|
+
onDown: handler,
|
|
407
|
+
disabled: true
|
|
408
|
+
}));
|
|
409
|
+
var ev = {};
|
|
410
|
+
subject.simulate('mousedown', ev);
|
|
411
|
+
var beforeUp = subject.state('active');
|
|
412
|
+
subject.simulate('mouseup', ev);
|
|
413
|
+
var afterUp = subject.state('active');
|
|
414
|
+
var expected = true;
|
|
415
|
+
var actual = beforeUp === afterUp;
|
|
416
|
+
expect(actual).toBe(expected);
|
|
417
|
+
});
|
|
418
|
+
test('should not update active state on mouse down when preventDefault is called', function () {
|
|
419
|
+
var Component = (0, _Touchable["default"])({
|
|
420
|
+
activeProp: 'active'
|
|
421
|
+
}, DivComponent);
|
|
422
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
423
|
+
onDown: preventDefault
|
|
424
|
+
}));
|
|
425
|
+
var ev = {};
|
|
426
|
+
subject.simulate('mousedown', ev);
|
|
427
|
+
var beforeUp = subject.state('active');
|
|
428
|
+
subject.simulate('mouseup', ev);
|
|
429
|
+
var afterUp = subject.state('active');
|
|
430
|
+
var expected = true;
|
|
431
|
+
var actual = beforeUp === afterUp;
|
|
432
|
+
expect(actual).toBe(expected);
|
|
433
|
+
});
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
describe('touch', function () {
|
|
437
|
+
test('should only emit onTap once when tapping an child instance of Touchable', function () {
|
|
438
|
+
var Component = (0, _Touchable["default"])(DivComponent);
|
|
439
|
+
var handler = jest.fn();
|
|
440
|
+
var subject = (0, _enzyme.mount)( /*#__PURE__*/_react["default"].createElement(Component, {
|
|
441
|
+
onTap: handler,
|
|
442
|
+
id: "outer"
|
|
443
|
+
}, /*#__PURE__*/_react["default"].createElement(Component, {
|
|
444
|
+
id: "inner"
|
|
445
|
+
})));
|
|
446
|
+
var mouseEvent = {
|
|
447
|
+
timeStamp: 1
|
|
448
|
+
};
|
|
449
|
+
var touchEvent = {
|
|
450
|
+
timeStamp: 1,
|
|
451
|
+
changedTouches: [{
|
|
452
|
+
clientX: 0,
|
|
453
|
+
clientY: 0
|
|
454
|
+
}],
|
|
455
|
+
targetTouches: [{
|
|
456
|
+
clientX: 0,
|
|
457
|
+
clientY: 0
|
|
458
|
+
}]
|
|
459
|
+
};
|
|
460
|
+
var inner = subject.find('div#inner');
|
|
461
|
+
inner.simulate('touchstart', touchEvent);
|
|
462
|
+
inner.simulate('touchend', touchEvent);
|
|
463
|
+
inner.simulate('mousedown', mouseEvent);
|
|
464
|
+
inner.simulate('mouseup', mouseEvent);
|
|
465
|
+
var expected = 1;
|
|
466
|
+
var actual = handler.mock.calls.length;
|
|
467
|
+
expect(actual).toBe(expected);
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
});
|