'use strict';

var _chai;

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

var _sinon;

function _load_sinon() {
  return _sinon = _interopRequireDefault(require('sinon'));
}

var _listScope;

function _load_listScope() {
  return _listScope = _interopRequireDefault(require('../../../../src/api/consumer/lib/list-scope'));
}

var _exceptions;

function _load_exceptions() {
  return _exceptions = require('../../../../src/consumer/exceptions');
}

var _consumer;

function _load_consumer() {
  return _consumer = _interopRequireWildcard(require('../../../../src/consumer'));
}

var _globalConfig;

function _load_globalConfig() {
  return _globalConfig = require('../../../../src/global-config');
}

var _remotes;

function _load_remotes() {
  return _remotes = _interopRequireDefault(require('../../../../src/remotes/remotes'));
}

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

describe('ListScope', function () {
  var sandbox = void 0;
  before(function () {
    sandbox = (_sinon || _load_sinon()).default.createSandbox();
  });
  after(function () {
    sandbox.restore();
  });
  describe('list', function () {
    it('should list components outside a scope if scopeName is given', function () {
      sandbox.stub(_consumer || _load_consumer(), 'loadConsumer').returns(Promise.reject(new (_exceptions || _load_exceptions()).ConsumerNotFound()));
      sandbox.stub((_globalConfig || _load_globalConfig()).GlobalRemotes, 'load').returns(Promise.resolve({ toPlainObject: function toPlainObject() {} }));
      var listSpy = sandbox.spy();
      var resolveStub = sandbox.stub((_remotes || _load_remotes()).default.prototype, 'resolve').returns(Promise.resolve({ list: listSpy }));

      var result = (0, (_listScope || _load_listScope()).default)({ scopeName: 'non-exists-scope' });
      (0, (_chai || _load_chai()).expect)(result).to.be.a('Promise');

      return result.then(function () {
        (0, (_chai || _load_chai()).expect)(resolveStub.getCall(0).args[0]).to.equal('non-exists-scope');
        (0, (_chai || _load_chai()).expect)(listSpy.called).to.be.true;
      });
    }).timeout(5000);
  });
});