UNPKG

qt-public-ui

Version:

新设计规范下业务组件库

67 lines (61 loc) 2.26 kB
import React, { useRef, useEffect, useState } from 'react'; import { mount } from 'enzyme'; import HorizontalScroll from '../'; var word = ['Home Loan Account', 'Plastic', 'Buckinghamshire', 'yellow', 'Vermont', 'Viaduct', 'Ethiopian Birr', 'indigo', 'Cambridgeshire', 'facilitate', 'parallelism', 'Legacy', 'compress', 'Steel', 'leading-edge', 'Identity', 'migration', 'Practical', 'Integration', 'white', 'Well', 'Markets', 'port', 'Saudi Arabia', 'Wooden', 'Money Market Account', 'virtual', 'Hollow']; var style = { border: '1px solid #ddd', height: 100, width: 100, lineHeight: '100px', textAlign: 'center', textOverflow: 'ellipsis', overflow: 'hidden' }; var Demo = function Demo() { var ref = useRef(); var _useState = useState(false), visible = _useState[0], setVisible = _useState[1]; useEffect(function () { console.log(11111, getComputedStyle(ref.current)); if (parseInt(getComputedStyle(ref.current).width) > 100) { setVisible(true); } // if(ref.current.width > 100){ // setVisible(true); // } }, [ref.current]); return /*#__PURE__*/React.createElement("div", { id: "cxw", style: { width: 500 }, ref: ref }, visible && 123123123123123); }; describe('DynamicList', function () { it('next', function () { // const container = <div style={{width: 500}}></div> // const container = global.document.createElement('div'); // container.style.width = '500px' var wrapper = mount( /*#__PURE__*/ // <Demo /> React.createElement("div", { style: { width: 500 } }, /*#__PURE__*/React.createElement(HorizontalScroll, null, word.map(function (w, index) { return /*#__PURE__*/React.createElement("div", { key: index, style: style }, w); }))) // { attachTo: container } ); // console.log(wrapper.find('.umui-scroll-arrow.umui-scroll-arrow-prev').exists(), wrapper.find('.umui-scroll-arrow.umui-scroll-arrow-next').exists()) expect(wrapper.render()).toMatchSnapshot(); // expect(wrapper.find('.umui-scroll-arrow.umui-scroll-arrow-prev').exists()).toEqual(false); // expect(wrapper.find('.umui-scroll-arrow.umui-scroll-arrow-next').exists()).toEqual(true); }); });