"use strict";

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

var _TimeRecordingService = _interopRequireDefault(require("../TimeRecordingService"));

describe('TimeRecordingService', function () {
  var timer;
  var updateTimeRemainingStub = sinon.stub();
  beforeEach(function () {
    var recordQuizTimeStub = function recordQuizTimeStub(cb) {
      cb({
        timerRecording: true
      });
    };

    timer = new _TimeRecordingService.default(recordQuizTimeStub, updateTimeRemainingStub);
  });
  afterEach(function () {
    updateTimeRemainingStub.resetHistory();
  });
  it('performs the API call immediately upon starting', function () {
    expect(updateTimeRemainingStub.callCount).to.eq(0);
    timer.start();
    expect(updateTimeRemainingStub.callCount).to.eq(1);
  });
  it('does not allow restarting', function () {
    timer.start();
    timer.stop();
    expect(function () {
      return timer.start();
    }).to.throw(Error);
  });
});