Skip to content

Instantly share code, notes, and snippets.

@Sparragus
Last active January 18, 2018 04:09
Show Gist options
  • Save Sparragus/a141ed70e664d13df7289ea135d87926 to your computer and use it in GitHub Desktop.
Save Sparragus/a141ed70e664d13df7289ea135d87926 to your computer and use it in GitHub Desktop.
// Icon.test.js
import React from 'react'
import { shallow } from 'enzyme'
import Icon from './Icon'
describe('Icon', () => {
let tree, props
const buildTree = (newProps = {}) => {
const defaultProps = {
name: 'add',
}
props = Object.assign({}, defaultProps, newProps)
return shallow(<Icon {...props} />)
}
it('matches the snapshot', () => {
tree = buildTree()
expect(
tree
).toMatchSnapshot()
})
it('adds the proper className given an icon name', () => {
tree = buildTree({ name: 'delete' })
expect(
tree.hasClass('icon-delete')
).toBe(
true
)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment