'use strict';

var _chai;

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

var _dists;

function _load_dists() {
  return _dists = _interopRequireDefault(require('../../../../src/consumer/component/sources/dists'));
}

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

describe('Dists', function () {
  describe('getNodePathDir', function () {
    var consumer = void 0;
    before(function () {
      consumer = { bitJson: {} };
      consumer.toAbsolutePath = function (src) {
        return src;
      };
    });
    it('should return null when custom module resolution is not configured', function () {
      (0, (_chai || _load_chai()).expect)((_dists || _load_dists()).default.getNodePathDir(consumer)).to.be.null;
    });
    it('when distTarget and distEntry are not configured it should return the default dist plus the customDir', function () {
      consumer.bitJson.resolveModules = { modulesDirectories: ['src'] };
      (0, (_chai || _load_chai()).expect)((_dists || _load_dists()).default.getNodePathDir(consumer)).to.equal('dist/src');
    });
    it('when distEntry equals to customDir it should return the distTarget', function () {
      consumer.bitJson.distTarget = 'dist';
      consumer.bitJson.distEntry = 'src';
      consumer.bitJson.resolveModules = { modulesDirectories: ['src'] };
      (0, (_chai || _load_chai()).expect)((_dists || _load_dists()).default.getNodePathDir(consumer)).to.equal('dist');
    });
    it('when distEntry starts with customDir it should return the distTarget + (customDir - distEntry)', function () {
      consumer.bitJson.distTarget = 'dist';
      consumer.bitJson.distEntry = 'src';
      consumer.bitJson.resolveModules = { modulesDirectories: ['src/custom'] };
      (0, (_chai || _load_chai()).expect)((_dists || _load_dists()).default.getNodePathDir(consumer)).to.equal('dist/custom');
    });
    it('when distEntry starts partially with customDir it should return the distTarget + (customDir - distEntry)', function () {
      consumer.bitJson.distTarget = 'dist';
      consumer.bitJson.distEntry = 'src';
      consumer.bitJson.resolveModules = { modulesDirectories: ['src2'] };
      (0, (_chai || _load_chai()).expect)((_dists || _load_dists()).default.getNodePathDir(consumer)).to.equal('dist/src2');
    });
    it('when there are many custom-dirs it should return them with a separator according to the OS', function () {
      consumer.bitJson.distTarget = 'dist';
      consumer.bitJson.distEntry = 'src';
      consumer.bitJson.resolveModules = { modulesDirectories: ['custom1', 'custom2'] };
      var delimiter = process.platform === 'win32' ? ';' : ':';
      (0, (_chai || _load_chai()).expect)((_dists || _load_dists()).default.getNodePathDir(consumer)).to.equal(`dist/custom1${delimiter}dist/custom2`);
    });
  });
});