'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _chai;

function _load_chai() {
  return _chai = require('chai');
}

var _removedComponents;

function _load_removedComponents() {
  return _removedComponents = require('./removed-components');
}

var _bitId;

function _load_bitId() {
  return _bitId = require('../bit-id');
}

describe('RemovedComponents', function () {
  var payload = {
    removedComponentIds: [],
    missingComponents: [],
    removedDependencies: [],
    dependentBits: {}
  };
  describe('fromObjects', function () {
    describe('with dependentBits', function () {
      var removeComponents = void 0;
      before(function () {
        var payloadWithDependents = _extends({}, payload);
        payloadWithDependents.dependentBits = {
          'sc/utils/is-type': [{ scope: 'sc', box: null, name: 'bar/foo', version: null }, { scope: 'sc', box: null, name: 'utils/is-string', version: null }]
        };
        removeComponents = (_removedComponents || _load_removedComponents()).RemovedObjects.fromObjects(payloadWithDependents);
      });
      it('should return an instance of RemovedObjects', function () {
        (0, (_chai || _load_chai()).expect)(removeComponents).to.be.instanceOf((_removedComponents || _load_removedComponents()).RemovedObjects);
      });
      it('dependentBits values should be BitIds', function () {
        (0, (_chai || _load_chai()).expect)(removeComponents.dependentBits).to.be.an('object');
        Object.keys(removeComponents.dependentBits).forEach(function (dependent) {
          (0, (_chai || _load_chai()).expect)(removeComponents.dependentBits[dependent]).to.be.instanceOf((_bitId || _load_bitId()).BitIds);
        });
      });
      it('each BitIds should have BitId objects', function () {
        Object.keys(removeComponents.dependentBits).forEach(function (dependent) {
          removeComponents.dependentBits[dependent].forEach(function (b) {
            return (0, (_chai || _load_chai()).expect)(b).to.be.instanceOf((_bitId || _load_bitId()).BitId);
          });
        });
      });
    });
  });
});