<commit_before><commit_msg>Specs for request student id component<commit_after>{Testing, expect, sinon, _, ReactTestUtils} = require 'openstax-react-components/test/helpers'

Course = require 'course/model'
RequestStudentId = require 'course/request-student-id'

describe 'RequestStudentId Component', ->

  beforeEach ->
    @props =
      onCancel: sinon.spy()
      onSubmit: sinon.spy()
      label: 'a test label'
      saveButtonLabel: 'this is save btn'
      title: 'this is title'
      course: new Course(ecosystem_book_uuid: 'test-collection-uuid')

  it 'renders values from props', ->
    Testing.renderComponent( RequestStudentId, props: @props ).then ({dom}) =>
      expect(dom.querySelector('h3').textContent).to.equal(@props.title)
      expect(dom.querySelector('.control-label').textContent).to.equal(@props.label)
      expect(dom.querySelector('.btn-default').textContent).to.equal(@props.saveButtonLabel)

  it 'calls onSubmit when save button is clicked', ->
    Testing.renderComponent( RequestStudentId, props: @props ).then ({dom}) =>
      expect(@props.onSubmit).not.to.have.been.called
      dom.querySelector('input').value = 'test value'
      Testing.actions.click(dom.querySelector('.btn-default'))
      expect(@props.onSubmit).to.have.been.calledWith('test value')

  it 'calls onCancel when cancel button is clicked', ->
    Testing.renderComponent( RequestStudentId, props: @props ).then ({dom}) =>
      expect(@props.onCancel).not.to.have.been.called
      Testing.actions.click(dom.querySelector('.cancel .btn'))
      expect(@props.onCancel).to.have.been.called
{'fraction_non_alphanumeric': 0.14472863381160325, 'fraction_numerical': 0.0006238303181534623, 'mean_word_length': 4.141025641025641, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4881157', 'n_tokens_mistral': 474, 'n_tokens_neox': 467, 'n_words': 96}