'use strict';

var _regenerator;

function _load_regenerator() {
  return _regenerator = _interopRequireDefault(require('babel-runtime/regenerator'));
}

var _chai;

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

var _sinon;

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

var _getScopeComponent;

function _load_getScopeComponent() {
  return _getScopeComponent = _interopRequireDefault(require('../../../../src/api/consumer/lib/get-scope-component'));
}

var _exceptions;

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

var _exceptions2;

function _load_exceptions2() {
  return _exceptions2 = require('../../../../src/scope/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'));
}

var _scope;

function _load_scope() {
  return _scope = _interopRequireWildcard(require('../../../../src/scope'));
}

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 }; }

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

describe('getScopeBit', function () {
  var sandbox = void 0;
  before(function () {
    sandbox = (_sinon || _load_sinon()).default.createSandbox();
  });
  after(function () {
    sandbox.restore();
  });
  // todo: it fails on Circle-CI for no reason. Fix it there, then, enable it here
  xit('should show a component when is running outside a scope', _asyncToGenerator( /*#__PURE__*/(_regenerator || _load_regenerator()).default.mark(function _callee() {
    var showSpy, resolveStub;
    return (_regenerator || _load_regenerator()).default.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            sandbox.stub(_consumer || _load_consumer(), 'loadConsumer').returns(Promise.reject(new (_exceptions || _load_exceptions()).ConsumerNotFound()));
            sandbox.stub(_scope || _load_scope(), 'loadScope').returns(Promise.reject(new (_exceptions2 || _load_exceptions2()).ScopeNotFound()));
            sandbox.stub((_globalConfig || _load_globalConfig()).GlobalRemotes, 'load').returns(Promise.resolve({ toPlainObject: function toPlainObject() {} }));
            showSpy = sandbox.spy();
            resolveStub = sandbox.stub((_remotes || _load_remotes()).default.prototype, 'resolve').returns(Promise.resolve({ show: showSpy }));
            _context.next = 7;
            return (0, (_getScopeComponent || _load_getScopeComponent()).default)({ id: 'my-scope/box/name' });

          case 7:
            (0, (_chai || _load_chai()).expect)(resolveStub.getCall(0).args[0]).to.equal('my-scope');
            (0, (_chai || _load_chai()).expect)(showSpy.called).to.be.true;

          case 9:
          case 'end':
            return _context.stop();
        }
      }
    }, _callee, undefined);
  })));
});