"use strict";

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

var _reactDom = _interopRequireDefault(require("react-dom"));

var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));

var _immutable = require("immutable");

var _ToggleDetails = _interopRequireDefault(require("@instructure/ui-toggle-details/lib/components/ToggleDetails"));

var _QuizSessionEvent = _interopRequireDefault(require("../../../../common/records/QuizSessionEvent"));

var _SessionStartEvent = _interopRequireDefault(require("../SessionStartEvent"));

describe('SessionStartEvent', function () {
  // testrail test_id: C2954596, C2954597, C2954603, C2954603 , C2954602
  var event = new _QuizSessionEvent.default((0, _immutable.fromJS)({
    createdAt: '2016-09-28T18:45:27.700Z|232982772',
    eventType: 'SESSION_STARTED_OR_RESUMED_EVENT',
    eventData: {
      browserSessionId: 'guid',
      clientTimestamp: '2016-09-28T18:45:25.300Z',
      userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2881.0 Safari/537.36' // eslint-disable-line max-len

    }
  }));
  var testbed = createTestbed(_SessionStartEvent.default, {
    event: event,
    startTime: new Date('2016-09-28T18:45:24.700Z|232982772')
  });

  var toggle = function toggle() {
    var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;

    var toggle = _reactDom.default.findDOMNode(testbed.findChildrenByType(_ToggleDetails.default)[index]);

    _testUtils.default.Simulate.click(toggle.querySelector('button'));
  };

  shouldRenderComponent(testbed, {}, _SessionStartEvent.default);
  it('should render a SessionStartEvent', function () {
    testbed.render();
    var sessionStartEventComponent = testbed.findChildrenByType(_SessionStartEvent.default)[0];
    expect(sessionStartEventComponent).to.not.be.undefined();
  });
  context('when dropdown is closed', function () {
    it('should show the dropdown toggle', function () {
      testbed.render();
      var toggleComponent = testbed.findChildrenByType(_ToggleDetails.default)[0];
      expect(toggleComponent).to.not.be.undefined();
    });
    it('should show the dropdown toggle summary', function () {
      testbed.render();
      var text = testbed.getText();
      expect(text).to.include('System details captured');
    });
    it('should not show the browser information', function () {
      testbed.render();
      var text = testbed.getText();
      expect(text).to.not.include('Browser');
    });
    it('should not show the operating system information', function () {
      testbed.render();
      var text = testbed.getText();
      expect(text).to.not.include('Operating System');
    });
  });
  context('when dropdown is open', function () {
    it('should show the browser information', function () {
      testbed.render();
      toggle();
      var text = testbed.getText();
      expect(text).to.include('BrowserChrome 55.0.2881.0');
    });
    it('should show the operating system information', function () {
      testbed.render();
      toggle();
      var text = testbed.getText();
      expect(text).to.include('Operating SystemOS X 10.11.6');
    });
  });
});