<commit_before>import "react-native"

import { renderWithWrappers } from "lib/tests/renderWithWrappers"
import React from "react"

import Artwork from "../ArtworkGridItem"

import { OwnerType } from "@artsy/cohesion"
import { Touchable } from "palette"
import { act } from "react-test-renderer"
import { useTracking } from "react-tracking"

it("renders without throwing an error", () => {
  renderWithWrappers(<Artwork artwork={artworkProps() as any} />)
})

describe("tracking", () => {
  const trackEvent = jest.fn()

  beforeEach(() => {
    ;(useTracking as any).mockImplementation(() => {
      return {
        trackEvent,
      }
    })
  })

  afterEach(() => {
    jest.clearAllMocks()
  })

  it("sends an event when trackTap is passed", () => {
    const trackTap = jest.fn()
    const rendered = renderWithWrappers(
      <Artwork trackTap={trackTap} artwork={artworkProps() as any} itemIndex={1} />
    )

    const touchableArtwork = rendered.root.findByType(Touchable)
    act(() => touchableArtwork.props.onPress())
    expect(trackTap).toBeCalledWith("cool-artwork", 1)
  })

  it("sends a tracking event when contextScreenOwnerType is included", () => {
    const rendered = renderer.create(
      <Theme>
        <Artwork
          artwork={artworkProps() as any}
          contextScreenOwnerType={OwnerType.artist}
          contextScreenOwnerId="abc124"
          contextScreenOwnerSlug="andy-warhol"
        />
      </Theme><commit_msg>Fix broken test<commit_after>import "react-native"

import { renderWithWrappers } from "lib/tests/renderWithWrappers"
import React from "react"

import Artwork from "../ArtworkGridItem"

import { OwnerType } from "@artsy/cohesion"
import { Touchable } from "palette"
import { act } from "react-test-renderer"
import { useTracking } from "react-tracking"

it("renders without throwing an error", () => {
  renderWithWrappers(<Artwork artwork={artworkProps() as any} />)
})

describe("tracking", () => {
  const trackEvent = jest.fn()

  beforeEach(() => {
    ;(useTracking as any).mockImplementation(() => {
      return {
        trackEvent,
      }
    })
  })

  afterEach(() => {
    jest.clearAllMocks()
  })

  it("sends an event when trackTap is passed", () => {
    const trackTap = jest.fn()
    const rendered = renderWithWrappers(<Artwork trackTap={trackTap} artwork={artworkProps() as any} itemIndex={1} />)

    const touchableArtwork = rendered.root.findByType(Touchable)
    act(() => touchableArtwork.props.onPress())
    expect(trackTap).toBeCalledWith("cool-artwork", 1)
  })

  it("sends a tracking event when contextScreenOwnerType is included", () => {
    const rendered = renderWithWrappers(
      <Artwork
        artwork={artworkProps() as any}
        contextScreenOwnerType={OwnerType.artist}
        contextScreenOwnerId="abc124"
        contextScreenOwnerSlug="andy-warhol"
      />
{'fraction_non_alphanumeric': 0.1372822299651568, 'fraction_numerical': 0.003484320557491289, 'mean_word_length': 3.608346709470305, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3403236', 'n_tokens_mistral': 900, 'n_tokens_neox': 885, 'n_words': 192}