"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _immutable = require("immutable");

var _reactTestbed = _interopRequireDefault(require("../../../../../../../tests/util/react-testbed"));

var _withContext = _interopRequireDefault(require("../../../../../../../tests/util/withContext"));

var _Stimulus = _interopRequireDefault(require("../../../../../records/Stimulus"));

var _presenter = _interopRequireDefault(require("../presenter"));

describe('StimulusEditInfo', function () {
  var modifyStub = sinon.stub();
  var stimulus = new _Stimulus.default({
    id: 55,
    title: 'Title',
    instructions: 'Instructions',
    body: 'Body',
    sourceUrl: 'Source URL'
  });
  var defaultProps = {
    stimulus: stimulus,
    workingStimulus: stimulus,
    fileUpload: sinon.stub(),
    modifyStimulus: modifyStub,
    progressValue: 0,
    setUploadStatus: sinon.stub()
  };
  var testbed = (0, _reactTestbed.default)((0, _withContext.default)(_presenter.default), defaultProps);
  afterEach(function () {
    modifyStub.resetHistory();
  });
  it('renders an error when there is a size error', function () {
    sinon.stub(stimulus, 'getErrors').returns((0, _immutable.fromJS)({
      onSelf: ['some error']
    }));
    testbed.render({
      errorsShowing: true
    });
    expect(testbed.getText()).to.include('some error');
  });
  describe('modifications', function () {
    var changeField = function changeField(inputNum, field) {
      testbed.render();
      var inputs = testbed.findChildrenByTagName('input');
      testbed.change(inputs[inputNum], 'hello');
      expect(modifyStub.firstCall.args[0].get(field)).to.eq('hello');
    };

    it('changes the title', function () {
      changeField(0, 'title');
    });
    it('changes the instructions', function () {
      changeField(1, 'instructions');
    });
    it('changes the source URL', function () {
      changeField(2, 'sourceUrl');
    });
  });
  describe('a11y tests', function () {
    it('should meet a11y standards', function (done) {
      testbed.render(); // ignoring button-name because of the textcolor tinymce plugin

      testbed.checkA11yStandards(done, {
        ignores: ['aria-allowed-role', // TODO: remove this when canvas-rce is fixed
        'button-name', 'label', 'label-title-only']
      });
    });
  });
});