{"size": 1016, "ext": "js", "max_stars_repo_path": "src/components/common/layout/Layout.test.js", "max_stars_repo_name": "nicorema/gatsby-todo-app", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/common/layout/Layout.test.js", "max_issues_repo_name": "nicorema/gatsby-todo-app", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/common/layout/Layout.test.js", "max_forks_repo_name": "nicorema/gatsby-todo-app", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.7804878049, "max_line_length": 68, "alphanum_fraction": 0.6338582677}
import React from 'react'
import renderer from 'react-test-renderer'
import { renderWithProviders } from '../../../TestUtils'

import Layout from './Layout'

describe('Layout', () => {
  const stickyAction = {
    onClick: jest.fn(),
  }
  const layoutCmp = renderer.create(
    renderWithProviders(
      <Layout title="test title" stickyAction={stickyAction}>
        <p>Testing child</p>
      </Layout>
    )
  )

  it('renders correctly', () => {
    const snapShot = layoutCmp.toJSON()
    expect(snapShot).toMatchSnapshot()
  })

  it('executes stickyAction on click', () => {
    layoutCmp.root.findByType('button').props.onClick()
    expect(stickyAction.onClick).toHaveBeenCalled()
  })

  it('does not render button when there is no stickyAction', () => {
    layoutCmp.update(
      renderWithProviders(
        <Layout title="test title">
          <p>Testing child</p>
        </Layout>
      )
    )
    const button = layoutCmp.root.findAllByType('button')
    expect(button).toHaveLength(0)
  })
})
