test('Posts to the resubmit URL', () => {
  $('#fixtures').append('<button id="resubmit-button">Click Here</button>')
  const previousAjaxJson = $.ajaxJSON
  $.ajaxJSON = sinon.spy()
  const event = {
    preventDefault: sinon.spy(),
    target: document.getElementById('resubmit-button')
  }
  SpeedgraderHelpers.plagiarismResubmitHandler(event, 'http://www.test.com')
  ok($.ajaxJSON.called)
  $.ajaxJSON = previousAjaxJson
})
test("prevents the button's default action", () => {
  $('#fixtures').append('<button id="resubmit-button">Click Here</button>')
  const ajaxStub = sinon.stub()
  ajaxStub.returns({
    status: 200,
    data: {}
  })
  const previousAjaxJson = $.ajaxJSON
  $.ajaxJSON = ajaxStub
  const event = {
    preventDefault: sinon.spy(),
    target: document.getElementById('resubmit-button')
  }
  SpeedgraderHelpers.plagiarismResubmitHandler(event, 'http://www.test.com')
  ok(event.preventDefault.called)
  $.ajaxJSON = previousAjaxJson
})
test('disables the button', () => {
  $('#fixtures').append('<button id="resubmit-button">Click Here</button>')
  const ajaxStub = sinon.stub()
  ajaxStub.returns({
    status: 200,
    data: {}
  })
  const previousAjaxJson = $.ajaxJSON
  $.ajaxJSON = ajaxStub
  const event = {
    preventDefault: sinon.spy(),
    target: $('#resubmit-button')
  }
  SpeedgraderHelpers.plagiarismResubmitHandler(event, 'http://www.test.com')
  equal($('#resubmit-button').attr('disabled'), 'disabled')
  $.ajaxJSON = previousAjaxJson
})
test("sets the 'anonymous' param to true if anonymizableUserId is 'anonymous_id'", () => {
  $('#fixtures').append('<button id="resubmit-button">Click Here</button>')
  const ajaxStub = sinon.stub()
  ajaxStub.returns({
    status: 200,
    data: {}
  })
  const previousAjaxJson = $.ajaxJSON
  $.ajaxJSON = ajaxStub
  const event = {
    preventDefault: sinon.spy(),
    target: document.getElementById('resubmit-button')
  }
  SpeedgraderHelpers.plagiarismResubmitHandler(event, 'http://www.test.com', 'anonymous_id')
  deepEqual(ajaxStub.args[0][2], {anonymous: true})
  $.ajaxJSON = previousAjaxJson
})