<commit_before>/* deps: coveralls istanbul */
require('mocha');
require('should');
var assert = require('assert');
var support = require('./support');
var Generate = support.resolve();
var Base = Generate.Base;
var generate;

describe('generate.compose', function() {
  beforeEach(function() {
    generate = new Generate();
  });

  it('should throw an error when trying to compose an instance', function(done) {
    var foo = new Generate({name: 'foo'});
    try {
      generate.compose(foo);
      done(new Error('Expected an error.'));
    } catch (err) {
      err.message.should.equal('generators must export a function to extend other generators');
      done();
    }
  });

  it('should compose a generator', function() {
    var foo = generate.generator('foo', function(app) {
      app.task('foo', function(cb) { cb(); });
    });

    var bar = generate.generator('bar', function(app) {
      app.task('bar', function(cb) { cb(); });
    });

    foo.tasks.should.have.property('foo');
    bar.tasks.should.have.property('bar');

    bar.tasks.should.not.have.property('foo');
    foo.tasks.should.not.have.property('bar');

    foo.compose(bar);
    bar.tasks.should.have.property('foo');
    bar.compose(foo);
    foo.tasks.should.have.property('bar');
  });

  it('should compose a generator by name', function() {
    var foo = generate.generator('foo', function(app) {
      app.task('foo', function(cb) { cb(); });
    });

    var bar = generate.generator('bar', function(app) {
      app.task('bar', function(cb) { cb(); });
    });

    foo.tasks.should.have.property('foo');
    bar.tasks.should.have.property('bar');

    bar.tasks.should.not.have.property('foo');
    foo.tasks.should.not.have.property('bar');

    generate.compose('foo', bar);
    bar.tasks.should.have.property('foo');
    generate.compose('bar', foo);
    foo.tasks.should.have.property('bar');
  });
});<commit_msg>minor formatting<commit_after>/* deps: coveralls istanbul */
require('mocha');
require('should');
var assert = require('assert');
var support = require('./support');
var Generate = support.resolve();
var Base = Generate.Base;
var generate;

describe('generate.compose', function() {
  beforeEach(function() {
    generate = new Generate();
  });

  it('should throw an error when trying to compose an instance', function(cb) {
    var foo = new Generate({name: 'foo'});
    try {
      generate.compose(foo);
      cb(new Error('Expected an error.'));
    } catch (err) {
      assert.equal(err.message, 'generators must export a function to extend other generators');
      cb();
    }
  });

  it('should compose a generator', function() {
    var foo = generate.generator('foo', function(app) {
      app.task('foo', function(cb) {
        cb();
      });
    });

    var bar = generate.generator('bar', function(app) {
      app.task('bar', function(cb) {
        cb();
      });
    });

    foo.tasks.should.have.property('foo');
    bar.tasks.should.have.property('bar');

    bar.tasks.should.not.have.property('foo');
    foo.tasks.should.not.have.property('bar');

    foo.compose(bar);
    bar.tasks.should.have.property('foo');
    bar.compose(foo);
    foo.tasks.should.have.property('bar');
  });

  it('should compose a generator by name', function() {
    var foo = generate.generator('foo', function(app) {
      app.task('foo', function(cb) {
        cb();
      });
    });

    var bar = generate.generator('bar', function(app) {
      app.task('bar', function(cb) {
        cb();
      });
    });

    foo.tasks.should.have.property('foo');
    bar.tasks.should.have.property('bar');

    bar.tasks.should.not.have.property('foo');
    foo.tasks.should.not.have.property('bar');

    generate.compose('foo', bar);
    bar.tasks.should.have.property('foo');
    generate.compose('bar', foo);
    foo.tasks.should.have.property('bar');
  });
});
{'fraction_non_alphanumeric': 0.19030428055698814, 'fraction_numerical': 0.0, 'mean_word_length': 3.2626373626373626, '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': '5597046', 'n_tokens_mistral': 1221, 'n_tokens_neox': 1184, 'n_words': 238}