<commit_before>'use strict';

require('mocha');
var assert = require('assert');
var Base = require('base').namespace('test');
var assemble = require('assemble-core');
var pipeline = require('base-pipeline');
var generators = require('base-generators');
var questions = require('base-questions');
var compose = require('./');
var app;
var base;

describe('base-compose', function() {
  beforeEach(function() {
    base = assemble();
    base.use(generators());
    base.use(compose());

    app = assemble();
    app.use(generators());
    app.use(compose());
  });

  it('should add `.compose` method to `app`', function() {
    assert.equal(typeof app.compose, 'function');
  });

  it('should not have any generators if none are passed', function() {
    assert.deepEqual(app.compose(base).generators, []);
  });

  it('should throw an error when "base-generators" is not registered', function(cb) {
    try {
      app = new Base();
      app.isApp = true;
      app.use(compose());
      app.compose();
      cb(new Error('expected an error'));
    } catch (err) {
      assert.equal(err.message, 'expected the base-generators plugin to be registered');
      cb();
    }
  });

  it('should throw an error when "parent" is not passed in', function(cb) {
    try {
      app.compose();
      cb(new Error('expected an error'));
    } catch (err) {
      assert.equal(err.message, 'expected the base-generators plugin to be registerd on "parent"');
      cb();
    }
  });

  describe('options', function() {
    it('should copy options from `a` to `app`', function() {
      var a = base.register('a', function(a) {
        a.option('foo', 'aaa');
      });

      app.compose(base, ['a'])
        .options();

      assert.deepEqual(app.options, a.options);
    });

    it('should copy options from `a` to `app` specified by property path', function() {
      base.register('a', function(a) {<commit_msg>add tests for using `app.base`<commit_after>'use strict';

require('mocha');
var assert = require('assert');
var Base = require('base').namespace('test');
var assemble = require('assemble-core');
var pipeline = require('base-pipeline');
var generators = require('base-generators');
var questions = require('base-questions');
var compose = require('./');
var app;
var base;

describe('base-compose', function() {
  beforeEach(function() {
    base = assemble();
    base.use(generators());
    base.use(compose());

    app = assemble();
    app.parent = base;
    app.use(generators());
    app.use(compose());
  });

  it('should add `.compose` method to `app`', function() {
    assert.equal(typeof app.compose, 'function');
  });

  it('should not have any generators if none are passed', function() {
    assert.deepEqual(app.compose().generators, []);
  });

  it('should use `base` when parent is not passed', function() {
    assert.deepEqual(app.compose().src, base);
  });

  it('should allow passing in an array of generators and use `base` when parent is not passed', function() {
    assert.deepEqual(app.compose('a').src, base);
    assert.deepEqual(app.compose('a').generators, ['a']);
    assert.deepEqual(app.compose().src, base);
    assert.deepEqual(app.compose(['a', 'b', 'c']).generators, ['a', 'b', 'c']);
  });

  it('should throw an error when "base-generators" is not registered', function(cb) {
    try {
      app = new Base();
      app.isApp = true;
      app.use(compose());
      app.compose();
      cb(new Error('expected an error'));
    } catch (err) {
      assert.equal(err.message, 'expected the base-generators plugin to be registered');
      cb();
    }
  });

  describe('options', function() {
    it('should copy options from `a` to `app`', function() {
      var a = base.register('a', function(a) {
        a.option('foo', 'aaa');
      });

      app.compose(base, ['a'])
        .options();

      assert.deepEqual(app.options, a.options);
    });

    it('should copy options from `a` to `app` specified by property path', function() {
      base.register('a', function(a) {
{'fraction_non_alphanumeric': 0.1810515873015873, 'fraction_numerical': 0.0, 'mean_word_length': 3.412472647702407, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1381943', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1224, 'n_words': 332}