UNPKG

@gechiui/block-editor

Version:
60 lines (47 loc) 1.49 kB
/** * External dependencies */ import { shallow } from 'enzyme'; /** * GeChiUI dependencies */ import { Icon } from '@gechiui/components'; import { image } from '@gechiui/icons'; /** * Internal dependencies */ import BlockIcon from '../'; describe( 'BlockIcon', () => { it( 'renders a Icon', () => { const wrapper = shallow( <BlockIcon icon={ image } /> ); expect( wrapper.containsMatchingElement( <Icon icon={ image } /> ) ).toBe( true ); } ); it( 'renders a span without the has-colors classname', () => { const wrapper = shallow( <BlockIcon icon={ image } /> ); expect( wrapper.find( 'span' ).hasClass( 'has-colors' ) ).toBe( false ); } ); it( 'renders a span with the has-colors classname', () => { const wrapper = shallow( <BlockIcon icon={ image } showColors /> ); expect( wrapper.find( 'span' ).hasClass( 'has-colors' ) ).toBe( true ); } ); it( 'skips adding background and foreground styles when colors are not enabled', () => { const wrapper = shallow( <BlockIcon icon={ { background: 'white', foreground: 'black' } } /> ); expect( wrapper.find( 'span' ).prop( 'style' ) ).toEqual( {} ); } ); it( 'adds background and foreground styles when colors are enabled', () => { const wrapper = shallow( <BlockIcon icon={ { background: 'white', foreground: 'black' } } showColors /> ); expect( wrapper.find( 'span' ).prop( 'style' ) ).toEqual( { backgroundColor: 'white', color: 'black', } ); } ); } );