import React from 'react'
import renderer from 'react-test-renderer'
import Notifications from '..'

describe('packages/ui', () => {
  it('renders correctly', () => {
    const wrapper = renderer
      .create(
        <Notifications className="foo">{() => <p>Hello</p>}</Notifications>
      )
      .toJSON()
    expect(wrapper).toMatchSnapshot()
  })

  it('renders a notification twice', () => {
    const tree = renderer.create(
      <Notifications>
        {(notify) => (
          <button
            onClick={() =>
              notify({ text: 'wat', title: 'wat', kind: 'danger' })
            }
          >
            wat
          </button>
        )}
      </Notifications>
    )

    const btn = tree.root.find((element) => element.type === 'button')
    btn.props.onClick()
    btn.props.onClick()

    expect(tree.toJSON()).toMatchSnapshot()
  })
})
