|
| 1 | +import React from 'react' |
| 2 | +import { shallow } from 'enzyme' |
| 3 | + |
| 4 | +import { NAMESPACE } from '../../../constants' |
| 5 | +import { Scroll } from '../' |
| 6 | + |
| 7 | +describe('<Scroll />', () => { |
| 8 | + it('passes in an optional className override', () => { |
| 9 | + const $ = shallow(<Scroll className="something else">_</Scroll>) |
| 10 | + expect($.hasClass(`${NAMESPACE}c-scroll`)).toBe(true) |
| 11 | + expect($.hasClass('something else')).toBe(true) |
| 12 | + }) |
| 13 | + |
| 14 | + it('renders a defined tag type', () => { |
| 15 | + const $ = shallow(<Scroll tag="article">_</Scroll>) |
| 16 | + expect($.type()).toBe('article') |
| 17 | + }) |
| 18 | + |
| 19 | + it('renders a div by default', () => { |
| 20 | + const $ = shallow(<Scroll>_</Scroll>) |
| 21 | + expect($.type()).toBe('div') |
| 22 | + }) |
| 23 | + |
| 24 | + it('renders with attributes', () => { |
| 25 | + const $ = shallow( |
| 26 | + <Scroll style={{ position: 'relative' }} ariaHidden> |
| 27 | + _ |
| 28 | + </Scroll> |
| 29 | + ) |
| 30 | + expect($.prop('style')).toEqual({ |
| 31 | + position: 'relative' |
| 32 | + }) |
| 33 | + expect($.prop('ariaHidden')).toBe(true) |
| 34 | + }) |
| 35 | + |
| 36 | + it('renders children', () => { |
| 37 | + const $ = shallow(<Scroll>test child</Scroll>) |
| 38 | + expect($.contains('test child')).toBe(true) |
| 39 | + }) |
| 40 | + |
| 41 | + it('renders a maxWidth and maxHeight', () => { |
| 42 | + const $ = shallow(<Scroll maxWidth="100px" maxHeight="500px">_</Scroll>) |
| 43 | + expect($.prop('style')).toEqual({ |
| 44 | + maxWidth: '100px', |
| 45 | + maxHeight: '500px' |
| 46 | + }) |
| 47 | + }) |
| 48 | +}) |
0 commit comments