'use strict';

var _chai;

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

var _sinon;

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

var _consumerComponent;

function _load_consumerComponent() {
  return _consumerComponent = _interopRequireDefault(require('../../../src/consumer/component/consumer-component'));
}

var _bitId;

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

var _impl;

function _load_impl() {
  return _impl = _interopRequireDefault(require('../../../src/consumer/component/sources/impl'));
}

var _constants;

function _load_constants() {
  return _constants = require('../../../src/constants');
}

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

describe.skip('ConsumerComponent', function () {
  describe('build', function () {
    var consumerComponent = void 0;
    before(function () {
      var bitId = new (_bitId || _load_bitId()).default({ scope: 'scope', box: 'box', name: 'name', version: 2 });
      consumerComponent = new (_consumerComponent || _load_consumerComponent()).default({
        name: 'component-name',
        box: 'box',
        version: 1,
        scope: 'myScope',
        implFile: '',
        specsFile: '',
        compilerId: bitId,
        testerId: bitId,
        dependencies: {},
        packageDependencies: {},
        impl: 'impl',
        specs: 'specs'
      });
      (_sinon || _load_sinon()).default.stub((_impl || _load_impl()).default, ['load']).returns('impl');
    });

    it('should use the ".js" extension for the impl dist file when the lang attribute was not set', function () {
      (0, (_chai || _load_chai()).expect)(consumerComponent.distImplFileName).to.equal('impl.js');
    });

    it('should use the ".js" extension for the spec dist file when the lang attribute was not set', function () {
      (0, (_chai || _load_chai()).expect)(consumerComponent.distSpecFileName).to.equal('spec.js');
    });

    it('should throw an error for a mismatch compiler interface', function () {
      var scope = {
        loadEnvironment: function loadEnvironment() {
          return {};
        }
      };
      var result = consumerComponent.build({ scope });
      (0, (_chai || _load_chai()).expect)(result).to.be.a('Promise');
      return result.then(function () {
        throw new Error('Promise should fail');
      }).catch(function (err) {
        (0, (_chai || _load_chai()).expect)(err).to.eql(`"scope/box/name${(_constants || _load_constants()).VERSION_DELIMITER}2" does not have a valid compiler interface, it has to expose a build method`);
      });
    });

    xit('should NOT throw an error for a correct compiler interface', function () {
      var scope = {
        loadEnvironment: function loadEnvironment() {
          return { compile: function compile() {
              return '';
            } };
        }
      };
      var result = consumerComponent.build({ scope });
      (0, (_chai || _load_chai()).expect)(result).to.be.a('Promise');
      return result.then().catch(function () {
        throw new Error('Promise should succeed');
      });
    });
  });
});