<commit_before>/* eslint-disable no-unused-expressions */
import React from 'react'
import { expect } from 'chai'
import { mountWithIntl } from 'intl/helpers'
import { Draft } from 'mobrender/widgets/draft/components'
import widgetsConfig from 'mobrender/widgets/config'

describe('client/mobrender/widgets/draft/components/draft', () => {
  const props = {
    mobilization: { id: 1 },
    widget: {
      id: 1,
      kind: 'draft',
      settings: {}
    },
    update: widget => widget
  }
  const widgets = widgetsConfig(props.mobilization, props.widget, {
    intl: { formatMessage: ({ defaultMessage }) => defaultMessage }
  })

  it('should render without crashed', () => {
    const draft = mountWithIntl(<Draft {...props} />)
    expect(draft).to.be.ok
  })

  it('should render buttons to update kind', () => {
    const plugins = widgets.filter(w => w.kind !== 'draft')
    const draft = mountWithIntl(<Draft {...props} />)
    expect(draft.find('DraftButton').length).to.equal(plugins.length)
  })

  it('should pass to update method widget props when clicked button', () => {
    let widgetProps
    const draft = mountWithIntl(
      <Draft {...props} update={props => { widgetProps = props }} />
    )
    const button = draft.find('DraftButton').at(1)
    button.find('button').simulate('click')
    const { kind, settings } = widgets.filter(w => w.kind === button.props().kind)[0]
    // Assert item to item
    expect(kind).to.equal(widgetProps.kind)
    expect(settings).to.deep.equal(widgetProps.settings)
    expect(props.widget.id).to.equal(widgetProps.id)
  })
})<commit_msg>chore: fix tests after add plip widget<commit_after>/* eslint-disable no-unused-expressions */
import React from 'react';
import { expect } from 'chai';
import { mountWithIntl } from 'intl/helpers';
import { Draft } from 'mobrender/widgets/draft/components';
import widgetsConfig from 'mobrender/widgets/config';

describe('client/mobrender/widgets/draft/components/draft', () => {
  const props = {
    mobilization: { id: 1 },
    widget: {
      id: 1,
      kind: 'draft',
      settings: {},
    },
    update: (widget) => widget,
  };
  const widgets = widgetsConfig(props.mobilization, props.widget, {
    intl: { formatMessage: ({ defaultMessage }) => defaultMessage },
  });

  it('should render without crashed', () => {
    const draft = mountWithIntl(<Draft {...props} />);
    expect(draft).to.be.ok;
  });

  it('should render buttons to update kind', () => {
    const plugins = widgets.filter(
      (w) => w.kind !== 'draft' && w.kind !== 'plip'
    );
    const draft = mountWithIntl(<Draft {...props} />);
    expect(draft.find('DraftButton').length).to.equal(plugins.length);
  });

  it('should pass to update method widget props when clicked button', () => {
    let widgetProps;
    const draft = mountWithIntl(
      <Draft
        {...props}
        update={(props) => {
          widgetProps = props;
        }}
      />
    );
    const button = draft.find('DraftButton').at(1);
    button.find('button').simulate('click');
    const { kind, settings } = widgets.filter(
      (w) => w.kind === button.props().kind
    )[0];
    // Assert item to item
    expect(kind).to.equal(widgetProps.kind);
    expect(settings).to.deep.equal(widgetProps.settings);
    expect(props.widget.id).to.equal(widgetProps.id);
  });
});
{'fraction_non_alphanumeric': 0.16836124401913877, 'fraction_numerical': 0.0023923444976076554, 'mean_word_length': 3.2234848484848486, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5941240', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1035, 'n_words': 227}