"use strict";

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

var _immutable = require("immutable");

var _QuizEntry = _interopRequireDefault(require("../../records/QuizEntry"));

var _Bank = _interopRequireDefault(require("../../records/Bank"));

var _generateDisplayPositions = _interopRequireDefault(require("../generateDisplayPositions"));

describe('generateDisplayPositions', function () {
  var bank = new _Bank.default({
    entryCount: 9,
    itemEntryCount: 9
  });
  var qe1 = new _QuizEntry.default();
  var qe2 = new _QuizEntry.default();
  var qe3 = new _QuizEntry.default({
    id: '8',
    entryType: 'Bank'
  });
  var qe4 = new _QuizEntry.default({
    id: '8',
    entryType: 'Stimulus'
  });
  var qe5 = new _QuizEntry.default();
  sinon.stub(qe3, 'getEntry').returns(bank);
  sinon.stub(qe4, 'getNestedEntries').returns((0, _immutable.List)([qe5, qe5, qe5]));
  it('returns an array of tuples of position - record', function () {
    var records = [qe1, qe2];
    var out = (0, _generateDisplayPositions.default)((0, _immutable.List)(records));
    expect(out.length).to.eq(2);
    expect(out[0].displayPosition).to.eq(1);
    expect(out[0].record).to.eq(qe1);
    expect(out[1].displayPosition).to.eq(2);
    expect(out[1].record).to.eq(qe2);
  });
  it('returns the correct number for displayPosition when nestedRecords are present', function () {
    var qe6 = new _QuizEntry.default();
    var records = [qe1, qe4, qe6, qe6, qe6, qe2, qe3, qe5];
    var out = (0, _generateDisplayPositions.default)((0, _immutable.List)(records));
    expect(out.length).to.eq(5);
    expect(out[0].displayPosition).to.eq(1);
    expect(out[0].record).to.eq(qe1); // Stimulus

    expect(out[1].displayPosition).to.eq(2);
    expect(out[1].record).to.eq(qe4);
    expect(out[2].displayPosition).to.eq(5);
    expect(out[2].record).to.eq(qe2); // Banks

    expect(out[3].displayPosition).to.eq(6);
    expect(out[3].record).to.eq(qe3);
    expect(out[4].displayPosition).to.eq(15);
    expect(out[4].record).to.eq(qe5);
  });
});