<commit_before><commit_msg>#6808 ShortTextRespondTask unit tests<commit_after>import React from 'react';
import { expect } from 'chai';
import { mountWithIntl } from './helpers/intl-test';

import ShortTextRespondTask from '../../src/app/components/task/ShortTextRespondTask';

describe('<ShortTextRespondTask />', () => {
  it('Hides buttons when not focused', () => {
    const task = mountWithIntl(<ShortTextRespondTask />);
    expect(task.find('.task__save')).to.have.length(0);
  });

  it('Cannot submit empty response', () => {
    const task = mountWithIntl(<ShortTextRespondTask />);
    task.setState({ response: '', focus: true });
    task.instance().canSubmit();
    expect(task.find('.task__save')).to.have.length(1);
    expect(task.find('.task__save').html()).to.contain('disabled=""');
  });

  it('Cannot submit a note without response', () => {
    const task = mountWithIntl(<ShortTextRespondTask />);
    task.setState({ note: 'a note', focus: true });
    task.instance().canSubmit();
    expect(task.find('.task__save')).to.have.length(1);
    expect(task.find('.task__save').html()).to.contain('disabled=""');
  });

  it('Can submit a response', () => {
    const task = mountWithIntl(<ShortTextRespondTask />);
    task.setState({ response: 'a response', focus: true });
    task.instance().canSubmit();
    expect(task.find('.task__save')).to.have.length(1);
    expect(task.find('.task__save').html()).to.not.contain('disabled=""');
  });

  it('Can edit a response', () => {
    const task = mountWithIntl(<ShortTextRespondTask response="text response" />);
    task.setState({ response: 'an edited response', focus: true });
    task.instance().canSubmit();
    expect(task.find('.task__save')).to.have.length(1);
    expect(task.find('.task__save').html()).to.not.contain('disabled=""');
  });

  it('Cannot remove a response', () => {
    const task = mountWithIntl(<ShortTextRespondTask response="text response" />);
    task.setState({ response: '', focus: true });
    task.instance().canSubmit();
    expect(task.find('.task__save')).to.have.length(1);
    expect(task.find('.task__save').html()).to.contain('disabled=""');
  });

  it('Can edit a note', () => {
    const task = mountWithIntl(<ShortTextRespondTask response="text response" note="text note" />);
    task.setState({ note: 'a note', focus: true });
    task.instance().canSubmit();
    expect(task.find('.task__save')).to.have.length(1);
    expect(task.find('.task__save').html()).to.not.contain('disabled=""');
  });
});
{'fraction_non_alphanumeric': 0.21069306930693069, 'fraction_numerical': 0.004356435643564357, 'mean_word_length': 4.455723542116631, 'pattern_counts': {'":': 0, '<': 11, '<?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': '5551728', 'n_tokens_mistral': 785, 'n_tokens_neox': 772, 'n_words': 132}