"use strict";

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

var _immutable = require("immutable");

var _index = _interopRequireDefault(require("../index"));

var _QuizSession = _interopRequireDefault(require("../../../../../records/QuizSession"));

var _SessionItemResult = _interopRequireDefault(require("../../../../../records/SessionItemResult"));

describe('QSRHeader', function () {
  var qs = new _QuizSession.default();
  var usersName = 'David Davidson';
  sinon.stub(qs, 'userDisplayName').returns(usersName); // Still relevant?

  var testbed = createTestbed(_index.default, {
    quizSession: qs
  });
  shouldRenderComponent(testbed, {}, _index.default);
  it('shows the users name', function () {
    testbed.render();
    expect(testbed.getText()).to.include(usersName);
  });
  it('includes the consumer provided subtitle (w/ user name) if provided', function () {
    testbed.render({
      studentDescription: 'Clark Kent'
    });
    expect(testbed.getText()).to.include('Clark Kent');
  });
  it('shows regrade alert if there are regradedSessionItemResults', function () {
    var regradedSessionItemResults = (0, _immutable.List)([new _SessionItemResult.default({
      position: '1',
      id: 1,
      regradeInfo: {
        regraded: true
      }
    }), new _SessionItemResult.default({
      position: '2',
      id: 2,
      regradeInfo: {
        regraded: true
      }
    })]);
    testbed.render({
      regradedSessionItemResults: regradedSessionItemResults
    });
    expect(testbed.getText()).to.include('This assessment has been regraded.');
  });
  it('shows regraded items by position', function () {
    var regradedSessionItemResults = (0, _immutable.List)([new _SessionItemResult.default({
      position: '2',
      id: 1,
      regradeInfo: {
        regraded: true
      }
    }), new _SessionItemResult.default({
      position: '3',
      id: 2,
      regradeInfo: {
        regraded: true
      }
    }), new _SessionItemResult.default({
      position: '5',
      id: 3,
      regradeInfo: {
        regraded: true
      }
    }), new _SessionItemResult.default({
      position: '8',
      id: 4,
      regradeInfo: {
        regraded: true
      }
    })]);
    testbed.render({
      regradedSessionItemResults: regradedSessionItemResults
    });
    expect(testbed.getText()).to.include('2, 3, 5, 8');
  });
  it('shows singular version of alert if there is only one regraded item', function () {
    var regradedSessionItem = (0, _immutable.List)([new _SessionItemResult.default({
      position: '1',
      id: 1,
      regradeInfo: {
        regraded: true
      }
    })]);
    testbed.render({
      regradedSessionItem: regradedSessionItem
    });
    expect(testbed.getText()).to.not.include('Questions');
  });
});