import * as React from 'react'; import {createDriverFactory} from 'wix-ui-test-utils/driver-factory'; import {isEnzymeTestkitExists} from 'wix-ui-test-utils/enzyme'; import {isTestkitExists} from 'wix-ui-test-utils/vanilla'; import {mount} from 'enzyme'; import {fullTextViewDriverFactory} from './FullTextView.driver'; import {fullTextViewUniDriverFactory} from './FullTextView.uni.driver'; import {FullTextView} from './FullTextView'; import {fullTextViewTestkitFactory} from '../../testkit'; import {fullTextViewTestkitFactory as enzymeFullTextViewTestkitFactory} from '../../testkit/enzyme'; import {createUniDriverFactory} from 'wix-ui-test-utils/dist/src/uni-driver-factory'; describe('FullTextView', () => { describe('[sync]', () => { runTests(createDriverFactory(fullTextViewDriverFactory)); }); describe('[async]', () => { runTests(createUniDriverFactory(fullTextViewUniDriverFactory)); }); function runTests(createDriver) { it('should render a span tag by default', async () => { const wrapper = createDriver(Hello World); expect(await wrapper.getTagName()).toBe('span'); }); it('should display full content on hover and hide it on leave in tooltip', async () => { const content = (
Delete this super awesome thing ?
); const component = mount({content}); expect(component.find('[data-hook="popover-content"]').length).toBe(0); component.setState({isEllipsisActive: true}); component.simulate('mouseEnter'); expect(component.find('[data-hook="popover-content"]').at(0).text()).toBe('Delete this super awesome thing?'); }); describe('testkit', () => { it('should exist', () => { expect(isTestkitExists(Hello World, fullTextViewTestkitFactory)).toBe(true); }); }); describe('enzyme testkit', () => { it('should exist', () => { expect(isEnzymeTestkitExists(Hello World, enzymeFullTextViewTestkitFactory, mount)).toBe(true); }); }); } });