<commit_before>define [
  'jquery'
  'Backbone'
  'compiled/views/accounts/admin_tools/CourseSearchResultsView'
  'compiled/models/CourseRestore'
], ($, Backbone, CourseSearchResultsView, CourseRestore) ->
  errorMessageJSON =
    status: "not_found"
    message: "There was no foo bar in the baz"

  courseJSON =
    account_id: 6
    course_code: "Super"
    default_view: "feed"
    end_at: null
    enrollments: []
    hide_final_grades: false
    id: 58
    name: "Super Fun Deleted Course"
    sis_course_id: null
    start_at: null
    workflow_state: "deleted"

  QUnit.module "CourseSearchResultsView",
    setup: ->
      @courseRestore = new CourseRestore account_id: 6
      @courseSearchResultsView = new CourseSearchResultsView model: @courseRestore
      $('#fixtures').append $('<div id="flash_screenreader_holder" />')
      $('#fixtures').append @courseSearchResultsView.render().el
    teardown: ->
      $('#fixtures').empty()

  test "restored is set to false when initialized", ->
    ok !@courseRestore.get('restored')

  test "render is called whenever the model has a change event triggered", ->
    @mock(@courseSearchResultsView).expects("render").once()

    @courseSearchResultsView.applyBindings()
    @courseRestore.trigger 'change'

  test "pressing the restore button calls restore on the model and view", ->
    @courseRestore.set courseJSON

    @mock(@courseRestore).expects("restore").once().
      returns($.Deferred().resolve())

    @courseSearchResultsView.$restoreCourseBtn.click()

  test "not found message is displayed when model has no id and a status", ->
    @courseRestore.clear silent: yes
    @courseRestore.set errorMessageJSON
    ok @courseSearchResultsView.$el.find('.alert-error').length > 0, "Error message is displayed"

  test "options to restore a course and its details should be displayed when a deleted course is found", ->
    @courseRestore.set courseJSON

    ok @courseSearchResultsView.$el.find('#restoreCourseBtn').length > 0, "Restore course button displayed"

  test "show screenreader text when course not found", ->
    $.initFlashContainer()
    @courseRestore.clear silent: yes
    @courseRestore.set errorMessageJSON
    @courseSearchResultsView.resultsFound()
    debugger
    ok $('#flash_screenreader_holder').text().match('Course not found')

  test "show screenreader text on finding deleted course", ->
    $.initFlashContainer()
    @courseRestore.set courseJSON
    @courseSearchResultsView.resultsFound()
    ok $('#flash_screenreader_holder').text().match('Course found')
<commit_msg>Spec: remove a debugger in search results spec<commit_after>define [
  'jquery'
  'Backbone'
  'compiled/views/accounts/admin_tools/CourseSearchResultsView'
  'compiled/models/CourseRestore'
], ($, Backbone, CourseSearchResultsView, CourseRestore) ->
  errorMessageJSON =
    status: "not_found"
    message: "There was no foo bar in the baz"

  courseJSON =
    account_id: 6
    course_code: "Super"
    default_view: "feed"
    end_at: null
    enrollments: []
    hide_final_grades: false
    id: 58
    name: "Super Fun Deleted Course"
    sis_course_id: null
    start_at: null
    workflow_state: "deleted"

  QUnit.module "CourseSearchResultsView",
    setup: ->
      @courseRestore = new CourseRestore account_id: 6
      @courseSearchResultsView = new CourseSearchResultsView model: @courseRestore
      $('#fixtures').append $('<div id="flash_screenreader_holder" />')
      $('#fixtures').append @courseSearchResultsView.render().el
    teardown: ->
      $('#fixtures').empty()

  test "restored is set to false when initialized", ->
    ok !@courseRestore.get('restored')

  test "render is called whenever the model has a change event triggered", ->
    @mock(@courseSearchResultsView).expects("render").once()

    @courseSearchResultsView.applyBindings()
    @courseRestore.trigger 'change'

  test "pressing the restore button calls restore on the model and view", ->
    @courseRestore.set courseJSON

    @mock(@courseRestore).expects("restore").once().
      returns($.Deferred().resolve())

    @courseSearchResultsView.$restoreCourseBtn.click()

  test "not found message is displayed when model has no id and a status", ->
    @courseRestore.clear silent: yes
    @courseRestore.set errorMessageJSON
    ok @courseSearchResultsView.$el.find('.alert-error').length > 0, "Error message is displayed"

  test "options to restore a course and its details should be displayed when a deleted course is found", ->
    @courseRestore.set courseJSON

    ok @courseSearchResultsView.$el.find('#restoreCourseBtn').length > 0, "Restore course button displayed"

  test "show screenreader text when course not found", ->
    $.initFlashContainer()
    @courseRestore.clear silent: yes
    @courseRestore.set errorMessageJSON
    @courseSearchResultsView.resultsFound()
    ok $('#flash_screenreader_holder').text().match('Course not found')

  test "show screenreader text on finding deleted course", ->
    $.initFlashContainer()
    @courseRestore.set courseJSON
    @courseSearchResultsView.resultsFound()
    ok $('#flash_screenreader_holder').text().match('Course found')

{'fraction_non_alphanumeric': 0.11337209302325581, 'fraction_numerical': 0.002325581395348837, 'mean_word_length': 4.14556331006979, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '4943555', 'n_tokens_mistral': 1502, 'n_tokens_neox': 1445, 'n_words': 398}