<commit_before>import React from 'react'
import Backbone from 'backbone'
import { mount } from 'enzyme'
import {
  Fixtures,
  IconEditEmbed,
  IconEditImages,
  IconEditText,
  IconEditVideo,
  IconHeroImage,
  IconHeroVideo
} from '@artsy/reaction-force/dist/Components/Publishing'
import SectionTool from '../index.jsx'
const { FeatureArticle } = Fixtures

describe('SectionTool', () => {
  const props = {
    isEditing: false,
    isHero: false,
    section: null,
    index: FeatureArticle.sections.length - 1,
    sections: new Backbone.Collection(FeatureArticle.sections),
  }

  it('opens on click', () => {
    const component = mount(
      <SectionTool {...props} />
    )
    component.find('.edit-tool__icon').simulate('click')
    expect(component.state().open).toBe(true)
  })

  it('renders the section icons when open', () => {
    const component = mount(
      <SectionTool {...props} />
    )
    component.find('.edit-tool__icon').simulate('click')
    expect(component.find(IconEditText).length).toBe(1)
    expect(component.find(IconEditImages).length).toBe(1)
    expect(component.find(IconEditVideo).length).toBe(1)
    expect(component.find(IconEditEmbed).length).toBe(1)
  })

  it('adds a new section of the correct type on click', () => {
    const originalSections = props.sections.length
    const component = mount(
      <SectionTool {...props} />
    )
    component.find('.edit-tool__icon').simulate('click')
    component.find(IconEditText).simulate('click')
    expect(component.props().sections.length).toBe(originalSections + 1)
    expect(component.props().sections.pop().get('type')).toMatch('text')
  })
})

describe('SectionTool: Hero', () => {
  const props = {
    isEditing: false,
    isHero: true,
    section: new Backbone.Model,
    index: -1,
    sections: new Backbone.Collection(FeatureArticle.sections),
    onSetEditing: jest.fn()<commit_msg>add tests for data-visible<commit_after>import React from 'react'
import Backbone from 'backbone'
import { mount } from 'enzyme'
import {
  Fixtures,
  IconEditEmbed,
  IconEditImages,
  IconEditText,
  IconEditVideo,
  IconHeroImage,
  IconHeroVideo
} from '@artsy/reaction-force/dist/Components/Publishing'
import SectionTool from '../index.jsx'
const { FeatureArticle } = Fixtures

describe('SectionTool', () => {
  const props = {
    isEditing: false,
    isHero: false,
    section: null,
    index: FeatureArticle.sections.length - 1,
    sections: new Backbone.Collection(FeatureArticle.sections)
  }

  it('opens on click', () => {
    const component = mount(
      <SectionTool {...props} />
    )
    component.find('.edit-tool__icon').simulate('click')
    expect(component.state().open).toBe(true)
  })

  it('renders the section icons when open', () => {
    const component = mount(
      <SectionTool {...props} />
    )
    component.find('.edit-tool__icon').simulate('click')
    expect(component.find(IconEditText).length).toBe(1)
    expect(component.find(IconEditImages).length).toBe(1)
    expect(component.find(IconEditVideo).length).toBe(1)
    expect(component.find(IconEditEmbed).length).toBe(1)
  })

  it('adds a new section of the correct type on click', () => {
    const originalSections = props.sections.length
    const component = mount(
      <SectionTool {...props} />
    )
    component.find('.edit-tool__icon').simulate('click')
    component.find(IconEditText).simulate('click')
    expect(component.props().sections.length).toBe(originalSections + 1)
    expect(component.props().sections.pop().get('type')).toMatch('text')
  })

  it('Adds a data-visible prop to the last section tool', () => {
    const component = mount(
      <SectionTool {...props} />
    )
    expect(component.html()).toMatch('data-visible="true"')
  })

  it('Adds a data-visible prop to the first section tool if no sections', () => {
    props.firstSection = true
    props.sections = new Backbone.Collection()
    const component = mount(
      <SectionTool {...props} />
    )
    expect(component.html()).toMatch('data-visible="true"')
  })
})

describe('SectionTool: Hero', () => {
  const props = {
    isEditing: false,
    isHero: true,
    section: new Backbone.Model,
    index: -1,
    sections: new Backbone.Collection(FeatureArticle.sections),
    onSetEditing: jest.fn()
{'fraction_non_alphanumeric': 0.15229016507788887, 'fraction_numerical': 0.0032550569634968614, 'mean_word_length': 3.665943600867679, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, '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': '7321390', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1316, 'n_words': 262}