"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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

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

  _chai = function () {
    return data;
  };

  return data;
}

function _sinon() {
  const data = _interopRequireDefault(require("sinon"));

  _sinon = function () {
    return data;
  };

  return data;
}

function _listScope() {
  const data = _interopRequireDefault(require("../../../api/consumer/lib/list-scope"));

  _listScope = function () {
    return data;
  };

  return data;
}

function _exceptions() {
  const data = require("../../../consumer/exceptions");

  _exceptions = function () {
    return data;
  };

  return data;
}

function consumer() {
  const data = _interopRequireWildcard(require("../../../consumer"));

  consumer = function () {
    return data;
  };

  return data;
}

function _globalConfig() {
  const data = require("../../../global-config");

  _globalConfig = function () {
    return data;
  };

  return data;
}

function _remotes() {
  const data = _interopRequireDefault(require("../../../remotes/remotes"));

  _remotes = function () {
    return data;
  };

  return data;
}

describe('ListScope', () => {
  let sandbox;
  before(() => {
    sandbox = _sinon().default.createSandbox();
  });
  after(() => {
    sandbox.restore();
  }); // @todo: currently this functionality is not working.
  // the migrate feature needs the consumer to be available and throw an error otherwise.

  describe.skip('list', () => {
    it('should list components outside a scope if scopeName is given', () => {
      sandbox.stub(consumer(), 'loadConsumer').returns(Promise.reject(new (_exceptions().ConsumerNotFound)()));
      sandbox.stub(_globalConfig().GlobalRemotes, 'load').returns(Promise.resolve({
        toPlainObject: () => {}
      }));
      const listSpy = sandbox.spy();
      const resolveStub = sandbox.stub(_remotes().default.prototype, 'resolve').returns(Promise.resolve({
        list: listSpy
      }));
      const result = (0, _listScope().default)({
        scopeName: 'non-exists-scope'
      });
      (0, _chai().expect)(result).to.be.a('Promise');
      return result.then(() => {
        (0, _chai().expect)(resolveStub.getCall(0).args[0]).to.equal('non-exists-scope');
        (0, _chai().expect)(listSpy.called).to.be.true;
      });
    }).timeout(5000);
  });
});