import * as React from 'react'; import {textDriverFactory} from './Text.driver'; import {isEnzymeTestkitExists} from 'wix-ui-test-utils/enzyme'; import {createDriverFactory} from 'wix-ui-test-utils/driver-factory'; import {isTestkitExists} from 'wix-ui-test-utils/vanilla'; import {Text} from './'; import {coreTextTestkitFactory as textTestkitFactory} from '../../../testkit'; import {coreTextTestkitFactory as enzymeTextTestkitFactory} from '../../../testkit/enzyme'; import {mount} from 'enzyme'; describe('Text', () => { const createDriver = createDriverFactory(textDriverFactory); describe('ellipsis attribute', () => { it('should not have ellipsis by default', () => { const driver = createDriver(Hello World); expect(driver.hasEllipsis()).toBeFalsy(); }); it('should have ellipsis', () => { const driver = createDriver(Hello World); expect(driver.hasEllipsis()).toBeTruthy(); }); }); describe('title attribute', () => { it('should not have title attribute by default', () => { const driver = createDriver(Hello World); expect(driver.hasTitleAttribute()).toBeFalsy(); }); it('should have title attribute when has ellipsis', () => { const driver = createDriver(Hello World); expect(driver.hasTitleAttribute()).toBeTruthy(); expect(driver.getTitle()).toBe('Hello World'); }); it('should not have title attribute when has ellipsis and children is an element', () => { const driver = createDriver(Hello World); expect(driver.hasTitleAttribute()).toBeFalsy(); }); it('should not have title attribute when has ellipsis and forceHideTitle is true', () => { const driver = createDriver(Hello World); expect(driver.hasTitleAttribute()).toBeFalsy(); }); }); describe('tagName prop', () => { it('should be span by default', () => { const driver = createDriver(Hello); expect(driver.getTagName()).toBe('span'); }); it('should be configueable', () => { const driver = createDriver(Hello); expect(driver.getTagName()).toBe('h1'); }); }); describe('children prop', () => { it('should be rendered when given as a string', () => { const children = 'Hello World'; const driver = createDriver({children}); expect(driver.getText()).toBe(children); }); it('should be rendered when given as an element', () => { const children =
Hello World
; const driver = createDriver({children}); expect(driver.getText()).toBe('
Hello World
'); }); }); describe('testkit', () => { it('should exist', () => { expect(isTestkitExists(Hello World, textTestkitFactory)).toBe(true); }); }); describe('enzyme testkit', () => { it('should exist', () => { expect(isEnzymeTestkitExists(Hello World, enzymeTextTestkitFactory, mount)).toBe(true); }); }); });