<commit_before>import React from 'react';
import { mount } from 'enzyme';
import BootstrapFormCheckbox from '../../../app/javascript/BuiltInFormControls/BootstrapFormCheckbox';
import BootstrapFormInput from '../../../app/javascript/BuiltInFormControls/BootstrapFormInput';
import BootstrapFormTextarea from '../../../app/javascript/BuiltInFormControls/BootstrapFormTextarea';
import CommonEventFormFields from '../../../app/javascript/BuiltInForms/CommonEventFormFields';
import RegistrationPolicyEditor from '../../../app/javascript/BuiltInFormControls/RegistrationPolicyEditor';
import TimespanItem from '../../../app/javascript/FormPresenter/components/TimespanItem';

describe('CommonEventFormFields', () => {
  const renderCommonEventFormFields = (props, eventProps) => mount((
    <CommonEventFormFields
      event={{
        category: 'larp',
        title: '',
        author: '',
        email: '',
        organization: '',
        con_mail_destination: 'gms',
        url: '',
        short_blurb: '',
        description: '',
        participant_communications: '',
        can_play_concurrently: false,
        maximum_event_provided_tickets_overrides: [],
        ...eventProps,
      }}
      ticketTypes={[]}
      onChange={() => {}}
      createMaximumEventProvidedTicketsOverride={() => {}}
      deleteMaximumEventProvidedTicketsOverride={() => {}}
      updateMaximumEventProvidedTicketsOverride={() => {}}
      {...props}
    />
  ));

  test('it renders values correctly', () => {
    const registrationPolicy = {
      buckets: [
        {
          key: 'players',
          name: 'Players',
          description: 'Players for this larp',
          slots_limited: true,
          anything: false,
          minimum_slots: 20,
          preferred_slots: 25,
          total_slots: 30,
        },
      ],
    };

    const component = renderCommonEventFormFields({}, {
      title: 'myTitle',
      author: 'myAuthor',
      email: 'myEmail',
      organization: 'myOrganization',
      con_mail_destination: 'event_email',
      url: 'myUrl',
      short_blurb: 'myShortBlurb',
      description: 'myDescription',
      participant_communications: 'myParticipantCommunications',
      length_seconds: 3600,
      registration_policy: registrationPolicy,
      can_play_concurrently: true,
    });

    expect(component.find(BootstrapFormInput).filter({ name: 'title' }).prop('value')).toEqual('myTitle');
    expect(component.find(BootstrapFormInput).filter({ name: 'author' }).prop('value')).toEqual('myAuthor');
    expect(component.find(BootstrapFormInput).filter({ name: 'email' }).prop('value')).toEqual('myEmail');
    expect(component.find(BootstrapFormInput).filter({ name: 'organization' }).prop('value')).toEqual('myOrganization');
    expect(component.find(BootstrapFormCheckbox).filter({ name: 'con_mail_destination', value: 'event_email' }).prop('checked')).toBeTruthy();
    expect(component.find(BootstrapFormInput).filter({ name: 'url' }).prop('value')).toEqual('myUrl');
    expect(component.find(BootstrapFormTextarea).filter({ name: 'short_blurb' }).prop('value')).toEqual('myShortBlurb');
    expect(component.find(BootstrapFormTextarea).filter({ name: 'description' }).prop('value')).toEqual('myDescription');
    expect(component.find(BootstrapFormTextarea).filter({ name: 'participant_communications' }).prop('value')).toEqual('myParticipantCommunications');
    expect(component.find(TimespanItem).prop('value')).toEqual(3600);<commit_msg>Test fix<commit_after>import React from 'react';
import { mount } from 'enzyme';
import BootstrapFormCheckbox from '../../../app/javascript/BuiltInFormControls/BootstrapFormCheckbox';
import BootstrapFormInput from '../../../app/javascript/BuiltInFormControls/BootstrapFormInput';
import BootstrapFormTextarea from '../../../app/javascript/BuiltInFormControls/BootstrapFormTextarea';
import CommonEventFormFields from '../../../app/javascript/BuiltInForms/CommonEventFormFields';
import RegistrationPolicyEditor from '../../../app/javascript/BuiltInFormControls/RegistrationPolicyEditor';
import TimespanItem from '../../../app/javascript/FormPresenter/components/TimespanItem';

describe('CommonEventFormFields', () => {
  const renderCommonEventFormFields = (props, eventProps) => mount((
    <CommonEventFormFields
      event={{
        category: 'larp',
        title: '',
        author: '',
        email: '',
        organization: '',
        con_mail_destination: 'gms',
        url: '',
        short_blurb: '',
        description: '',
        participant_communications: '',
        can_play_concurrently: false,
        maximum_event_provided_tickets_overrides: [],
        ...eventProps,
      }}
      ticketTypes={[]}
      onChange={() => {}}
      createMaximumEventProvidedTicketsOverride={() => {}}
      deleteMaximumEventProvidedTicketsOverride={() => {}}
      updateMaximumEventProvidedTicketsOverride={() => {}}
      {...props}
    />
  ));

  test('it renders values correctly', () => {
    const registrationPolicy = {
      buckets: [
        {
          key: 'players',
          name: 'Players',
          description: 'Players for this larp',
          slots_limited: true,
          anything: false,
          minimum_slots: 20,
          preferred_slots: 25,
          total_slots: 30,
        },
      ],
      prevent_no_preference_signups: false,
    };

    const component = renderCommonEventFormFields({}, {
      title: 'myTitle',
      author: 'myAuthor',
      email: 'myEmail',
      organization: 'myOrganization',
      con_mail_destination: 'event_email',
      url: 'myUrl',
      short_blurb: 'myShortBlurb',
      description: 'myDescription',
      participant_communications: 'myParticipantCommunications',
      length_seconds: 3600,
      registration_policy: registrationPolicy,
      can_play_concurrently: true,
    });

    expect(component.find(BootstrapFormInput).filter({ name: 'title' }).prop('value')).toEqual('myTitle');
    expect(component.find(BootstrapFormInput).filter({ name: 'author' }).prop('value')).toEqual('myAuthor');
    expect(component.find(BootstrapFormInput).filter({ name: 'email' }).prop('value')).toEqual('myEmail');
    expect(component.find(BootstrapFormInput).filter({ name: 'organization' }).prop('value')).toEqual('myOrganization');
    expect(component.find(BootstrapFormCheckbox).filter({ name: 'con_mail_destination', value: 'event_email' }).prop('checked')).toBeTruthy();
    expect(component.find(BootstrapFormInput).filter({ name: 'url' }).prop('value')).toEqual('myUrl');
    expect(component.find(BootstrapFormTextarea).filter({ name: 'short_blurb' }).prop('value')).toEqual('myShortBlurb');
    expect(component.find(BootstrapFormTextarea).filter({ name: 'description' }).prop('value')).toEqual('myDescription');
    expect(component.find(BootstrapFormTextarea).filter({ name: 'participant_communications' }).prop('value')).toEqual('myParticipantCommunications');
    expect(component.find(TimespanItem).prop('value')).toEqual(3600);
{'fraction_non_alphanumeric': 0.15719777872703972, 'fraction_numerical': 0.0039869001851060805, 'mean_word_length': 3.8575380359612725, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '3433761', 'n_tokens_mistral': 1932, 'n_tokens_neox': 1931, 'n_words': 310}