"use strict";

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

function _objectSpread2() {
  const data = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));

  _objectSpread2 = function () {
    return data;
  };

  return data;
}

function _chai() {
  const data = require("chai");

  _chai = function () {
    return data;
  };

  return data;
}

function _removedComponents() {
  const data = require("./removed-components");

  _removedComponents = function () {
    return data;
  };

  return data;
}

function _bitId() {
  const data = require("../bit-id");

  _bitId = function () {
    return data;
  };

  return data;
}

describe('RemovedComponents', () => {
  const payload = {
    removedComponentIds: [],
    missingComponents: [],
    removedDependencies: [],
    dependentBits: {}
  };
  describe('fromObjects', () => {
    describe('with dependentBits', () => {
      let removeComponents;
      before(() => {
        const payloadWithDependents = (0, _objectSpread2().default)({}, 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().RemovedObjects.fromObjects(payloadWithDependents);
      });
      it('should return an instance of RemovedObjects', () => {
        (0, _chai().expect)(removeComponents).to.be.instanceOf(_removedComponents().RemovedObjects);
      });
      it('dependentBits values should be BitIds', () => {
        (0, _chai().expect)(removeComponents.dependentBits).to.be.an('object');
        Object.keys(removeComponents.dependentBits).forEach(dependent => {
          (0, _chai().expect)(removeComponents.dependentBits[dependent]).to.be.instanceOf(_bitId().BitIds);
        });
      });
      it('each BitIds should have BitId objects', () => {
        Object.keys(removeComponents.dependentBits).forEach(dependent => {
          removeComponents.dependentBits[dependent].forEach(b => (0, _chai().expect)(b).to.be.instanceOf(_bitId().BitId));
        });
      });
    });
  });
});