"use strict";

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

var _immutable = require("immutable");

var _constants = require("@instructure/quiz-common/lib/constants");

var _upload = _interopRequireDefault(require("../upload"));

describe('upload reducer', function () {
  var file = 'FILE';

  var sharedExample = function sharedExample(initialState, action, stateKey, expectedResult) {
    var resultState = (0, _upload.default)(initialState, action);
    expect(resultState.get(stateKey)).to.eql(expectedResult);
  };

  describe('CLEAR_ALT_TEXT', function () {
    it('clears the altText', function () {
      var exampleAction = {
        type: _constants.CLEAR_ALT_TEXT
      };
      sharedExample((0, _immutable.Map)({
        altText: 'some text'
      }), exampleAction, 'altText', void 0);
    });
  });
  describe('CLEAR_FILES', function () {
    it('clears the files', function () {
      var exampleReceiveAction = {
        type: _constants.CLEAR_FILES
      };
      sharedExample((0, _immutable.Map)(), exampleReceiveAction, 'files', void 0);
    });
  });
  describe('FILE_RECEIVED', function () {
    it('sets files to the new file', function () {
      var exampleReceiveAction = {
        type: _constants.FILE_RECEIVED,
        payload: {
          file: [file]
        }
      };
      sharedExample((0, _immutable.Map)(), exampleReceiveAction, 'files', [file]);
    });
  });
  describe('FILE_UPLOAD_CALL', function () {
    it('sets files to empty', function () {
      var exampleUploadAction = {
        type: _constants.FILE_UPLOAD_CALL,
        payload: {
          file: []
        }
      };
      sharedExample((0, _immutable.Map)({
        files: [file]
      }), exampleUploadAction, 'files', []);
    });
  });
  describe('FILE_UPLOAD_STATUS', function () {
    it('sets files to empty', function () {
      var exampleUploadAction = {
        type: _constants.FILE_UPLOAD_STATUS,
        payload: {
          status: 'ASTATUS'
        }
      };
      sharedExample((0, _immutable.Map)({
        satus: 'FIRST_STATUS'
      }), exampleUploadAction, 'status', 'ASTATUS');
    });
  });
  describe('SET_ALT_TEXT', function () {
    it('sets the alt text', function () {
      var exampleAction = {
        type: _constants.SET_ALT_TEXT,
        payload: {
          altText: 'some alt text'
        }
      };
      sharedExample((0, _immutable.Map)({
        altText: ''
      }), exampleAction, 'altText', 'some alt text');
    });
  });
});