"use strict";

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

var _chai = require("chai");

var _Response = _interopRequireDefault(require("../Response"));

describe('Response', function () {
  describe('#constructor', function () {
    it('defaults attempt to null', function () {
      var response = new _Response.default();
      (0, _chai.expect)(response.attempt).to.be.null();
    });
    it('defaults itemId to null', function () {
      var response = new _Response.default();
      (0, _chai.expect)(response.itemId).to.be.null();
    });
    it('defaults largeFormatResponse to null', function () {
      var response = new _Response.default();
      (0, _chai.expect)(response.largeFormatResponse).to.be.null();
    });
    it('defaults position to null', function () {
      var response = new _Response.default();
      (0, _chai.expect)(response.position).to.be.null();
    });
    it('defaults userResponse to null', function () {
      var response = new _Response.default();
      (0, _chai.expect)(response.userResponse).to.be.null();
    });
    it('defaults id to null', function () {
      var response = new _Response.default();
      (0, _chai.expect)(response.id).to.be.null();
    });
  });
  describe('#getItem', function () {
    it('returns nothing if there is no itemId', function () {
      var response = new _Response.default();
      (0, _chai.expect)(response.getItem()).to.be.undefined();
    });
    it('gets the session item through the helper', function () {
      var response = new _Response.default({
        itemId: 'item1',
        id: 'id2'
      });
      var item = {};
      var getItem = sinon.stub().returns(item);
      var findSessionItem = sinon.stub().returns({
        getItem: getItem
      });

      response.stateHelper = function () {
        return {
          findSessionItem: findSessionItem
        };
      };

      (0, _chai.expect)(response.getItem()).to.equal(item);
      (0, _chai.expect)(findSessionItem.calledWith('id2')).to.be.true();
      (0, _chai.expect)(getItem.called).to.be.true();
    });
  });
});