Skip to content

Commit

Permalink
test(tooltip): Add test to check for trigger and bubble
Browse files Browse the repository at this point in the history
  • Loading branch information
lzcabrera committed Sep 29, 2017
1 parent 3043990 commit d82c0bd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/Tooltip/Tooltip.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Tooltip = ({ direction, children, ...rest }) => {
{children}
</span>
<button className={styles.trigger}>
<DecorativeIcon symbol="questionMarkCircle" />
<DecorativeIcon symbol="questionMarkCircle" size={16} />
</button>
</div>
)
Expand Down
21 changes: 19 additions & 2 deletions src/components/Tooltip/__tests__/Tooltip.spec.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import React from 'react'
import { shallow } from 'enzyme'
import { shallow, render } from 'enzyme'
import toJson from 'enzyme-to-json'

import Tooltip from '../Tooltip'

describe('Tooltip', () => {

const doRender = (overrides = {}) => render(
<Tooltip {...overrides}>Helper text</Tooltip>
)

const doShallow = (overrides = {}) => shallow(
<Tooltip {...overrides}>Helper text</Tooltip>
)

it('renders', () => {
const tooltip = doShallow()
const tooltip = doRender()

expect(toJson(tooltip)).toMatchSnapshot()
})
Expand All @@ -21,6 +26,18 @@ describe('Tooltip', () => {
expect(tooltip).toHaveTagName('div')
})

it('has a trigger'), () => {
const tooltip = doShallow()

expect(tooltip.find('button')).toContainReact(<DecorativeIcon symbol="questionMarkCircle" size={16} />)
}

it('has a bubble', () => {
const tooltip = doShallow()

expect(tooltip.find('span').text()).toEqual('Helper text')
})

// it('can set direction', () => {
// let tooltip = doShallow()
// expect(tooltip).toHaveClassName('right')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

exports[`Tooltip renders 1`] = `
<div
className="wrapper"
class="wrapper"
>
<span
className="right"
class="right"
>
Helper text
</span>
<button
className="trigger"
class="trigger"
>
<DecorativeIcon
size={24}
symbol="questionMarkCircle"
<i
aria-hidden="true"
class="iconQuestionMarkCircle size16"
/>
</button>
</div>
Expand Down

0 comments on commit d82c0bd

Please sign in to comment.