<commit_before>#= require application
#= require frontend

describe "Backbone.Factlink.TextAreaView", ->
  initialText = 'something.'
  sampleShortText = 'some text.'
  sampleLongText = 'Various\nbits\nof text\non\nseveral\nlines\n\n\n!'
  model = view = null

  textarea = -> view.$el.find('textarea')

  beforeEach ->
    model = new Backbone.Model({text: initialText})
    view = new Backbone.Factlink.TextAreaView(model: model)
    #since we need to check how layout works, we need to to include
    #the view in the document.
    $(document.body).append view.render().$el

  it "shows the text", ->
    expect(textarea().val()).to.equal initialText

  it "updates the textarea when the model changes", ->
    model.set text: sampleShortText
    expect(textarea().val()).to.equal sampleShortText

  it "updates the model when the textarea changes", ->
    textarea().val('bla - bla!')
    textarea().trigger 'keyup'
    expect(model.get('text')).to.equal 'bla - bla!'

  it "is initially small and scrollbarless", ->
    expect(textarea().height()).to.be.below 45
    expect(textarea()[0].scrollHeight).to.equal textarea()[0].clientHeight

  it "grows vertically and avoids a scrollbar when text doesn't fit", ->
    initialHeight = textarea().height()
    textarea().val sampleLongText
    textarea().trigger 'input'
    expect(textarea().height()).not.to.equal initialHeight
    expect(textarea()[0].scrollHeight).to.equal textarea()[0].clientHeight

  it "autosizes also whe the model is updated", ->
    initialHeight = textarea().height()
    model.set text: sampleLongText
    expect(textarea().height()).not.to.equal initialHeight<commit_msg>Fix failing build (test, not SUT) text area view now expects input to be focused for autosizing to work, and enlarges directly on focus.<commit_after>#= require application
#= require frontend

describe "Backbone.Factlink.TextAreaView", ->
  initialText = 'something.'
  sampleShortText = 'some text.'
  sampleLongText = 'Various\nbits\nof text\non\nseveral\nlines\n\n\n!'
  model = view = null

  textarea = -> view.$el.find('textarea')

  beforeEach ->
    model = new Backbone.Model({text: initialText})
    view = new Backbone.Factlink.TextAreaView(model: model)
    #since we need to check how layout works, we need to to include
    #the view in the document.
    $(document.body).append view.render().$el
    textarea().trigger 'focus'


  it "shows the text", ->
    expect(textarea().val()).to.equal initialText

  it "updates the textarea when the model changes", ->
    model.set text: sampleShortText
    expect(textarea().val()).to.equal sampleShortText

  it "updates the model when the textarea changes", ->
    textarea().val('bla - bla!')
    textarea().trigger 'keyup'
    expect(model.get('text')).to.equal 'bla - bla!'

  it "is initially small and scrollbarless", ->
    expect(textarea().height()).to.be.below 55
    expect(textarea()[0].scrollHeight).to.equal textarea()[0].clientHeight

  it "grows vertically and avoids a scrollbar when text doesn't fit", ->
    initialHeight = textarea().height()
    textarea().val sampleLongText
    textarea().trigger 'input'
    expect(textarea().height()).not.to.equal initialHeight
    expect(textarea()[0].scrollHeight).to.equal textarea()[0].clientHeight

  it "autosizes also whe the model is updated", ->
    initialHeight = textarea().height()
    model.set text: sampleLongText
    expect(textarea().height()).not.to.equal initialHeight
{'fraction_non_alphanumeric': 0.1375325050563421, 'fraction_numerical': 0.0034672060098237503, 'mean_word_length': 3.896746817538897, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '253582', 'n_tokens_mistral': 1061, 'n_tokens_neox': 993, 'n_words': 282}