generators.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*global describe before it */
  2. var path = require('path');
  3. var events = require('events');
  4. var assert = require('assert');
  5. var generators = require('..');
  6. describe('Generators', function () {
  7. before(generators.test.before(path.join(__dirname, 'temp')));
  8. describe('yeoman.generators', function () {
  9. it('should have a Base object to extend from', function () {
  10. assert.ok(generators.Base);
  11. });
  12. it('should have a NamedBase object to extend from', function () {
  13. assert.ok(generators.NamedBase);
  14. });
  15. });
  16. describe('yeoman.generators.Base', function () {
  17. before(function () {
  18. this.env = generators();
  19. this.generator = new generators.Base({
  20. env: this.env,
  21. resolved: 'test'
  22. });
  23. });
  24. it('should be an EventEmitter', function (done) {
  25. assert.ok(this.generator instanceof events.EventEmitter);
  26. assert.ok(typeof this.generator.on === 'function');
  27. assert.ok(typeof this.generator.emit === 'function');
  28. this.generator.on('yay-o-man', done);
  29. this.generator.emit('yay-o-man');
  30. });
  31. });
  32. describe('yeoman.generators.NamedBase', function () {
  33. before(function () {
  34. this.env = generators();
  35. this.generator = new generators.NamedBase(['namedArg'], {
  36. env: this.env,
  37. resolved: 'namedbase:test'
  38. });
  39. });
  40. it('should be a Base generator', function () {
  41. assert.ok(this.generator instanceof generators.Base);
  42. });
  43. it('and it should have a name property', function () {
  44. assert.equal(this.generator.name, 'namedArg');
  45. });
  46. });
  47. });