Пример #1
0
 questions.on('ask', function(val, key, question, answers) {
   if (count < 5) {
     count++;
     bddStdin('\n');
   } else {
     bddStdin('bar\n');
   }
 });
    "Check that generates a container properly": function (test) {
        var template_name = 'container';

        test.expect(1);

        bddStdin('container-test\n',
            'ssr\n', 'container-test\n',
            'testTemplate\n',
            'layouts\n', 'layouts\n', 'Personal\n',
            'P\n'
        );

        program.parse(['node', 'test', 'generate', template_name]);

        setTimeout(function () {
            dircompare
                .compare(path.join(__dirname, 'expected', 'container-test'), path.join(__dirname, 'generated', 'container-test'), dcOptions)
                .then(function (res) {
                    test.equals(res.distinct, 0, 'Both containers have the same content.');
                    test.done();
                })
                .catch(function (error) {
                    test.done();
                });
        }, timeout);
    },
    "Check that generates an agnostic widget properly": function (test) {
        var template_name = 'agnosthic-widget';

        test.expect(1);

        bddStdin('test\n',
            'agnostic-widget\n', 'Agnostic Widget\n',
            '1.0.0\n', 'author@company.com\n',
            'test\n', 'test\n', 'N\n', 'N\n',
            'a\n'
        );

        program.parse(['node', 'test', 'generate', template_name]);

        setTimeout(function () {
            dircompare
                .compare(path.join(__dirname, 'expected', 'agnostic-widget'), path.join(__dirname, 'generated', 'agnostic-widget'), dcOptions)
                .then(function (res) {
                    test.equals(res.distinct, 0, 'Both agnostic widgets have the same content.');
                    test.done();
                })
                .catch(function (error) {
                    test.done();
                });
        }, timeout);
    }
    "Check that generates a template properly": function (test) {
        var template_name = 'template';
        var expectedOutput = [
            chalk.gray('Generating ' + template_name + ' on path: ' + process.cwd())
        ];

        test.expect(2);

        bddStdin('Test Template\n',
            'testTemplate\n', 'Personal\n',
            'P\n', 'N\n', 'N\n', 'a\n'
        );

        program.parse(['node', 'test', 'generate', template_name]);

        expectedOutput.forEach(function (output, index) {
            test.equals(generatedOutput[index], output, 'Our command tool has found a valid template');
        });

        setTimeout(function () {
            dircompare
                .compare(path.join(__dirname, 'expected', 'test-template'), path.join(__dirname, 'generated', 'test-template'), dcOptions)
                .then(function (res) {
                    test.equals(res.distinct, 0, 'Both templates have the same content.');
                    test.done();
                })
                .catch(function (error) {
                    test.done();
                });
        }, timeout);
    },
Пример #5
0
    it('returns a promise, resolved on yes', function () {
      bddStdin('yes\n')

      return confirm('is this ok?').catch(function () {
        la(false, 'invalid response, should be resolved on yes')
      })
    })
Пример #6
0
Файл: add.js Проект: greg-js/wdn
 it('should not overwrite points with n-response', function() {
   stdin('n');
   return add(local, 'foo', ['./'], false, customConfig)
     .then(function(res) {
       expect(res.point).to.not.be.ok;
     });
 });
Пример #7
0
Файл: add.js Проект: greg-js/wdn
 it('should overwrite points with y-response', function() {
   stdin('y');
   return add(local, 'foo', ['./'], false, customConfig)
     .then(function(res) {
       expect(res.point).to.equal('foo');
       expect(res.path).to.equal(path.resolve(process.cwd()));
     });
 });
Пример #8
0
 it('should work with nested sub-generators', function(cb) {
   app
     .register('foo', generator)
     .register('bar', generator)
     .register('baz', generator);
   bddStdin('\n', '\n', '\n');
   app.generate('foo.bar.baz', exists('.babelrc', cb));
 });
Пример #9
0
 it('default value is false', () => {
   bddStdin('\n') // note we don't actually enter anything
   return confirm({question: 'pass extra?', extra: 42, default: false})
     .then(() => {
       la(false, 'should have picked default answer false')
     }, (value) => {
       la(value === 42, 'expected extra value on default answer false', value)
     })
 })
Пример #10
0
    it('should skip questions when options.skip is true', function(cb) {
      questions.set('foo', {skip: true});
      bddStdin('bar\n');
      questions.ask('foo', function(err, answers) {
        if (err) return cb(err);

        var question = questions.get('foo');
        assert.equal(question.skipped, true);
        assert.equal(typeof answers.foo, 'undefined');
        cb();
      });
    });
Пример #11
0
    it('should ask a question', function(cb) {
      var intercepted = interception('foo');
      questions.set('foo');
      bddStdin('bar\n');

      questions.ask('foo', function(err, answers) {
        if (err) return cb(err);
        assert.equal(answers.foo, 'bar');
        intercepted();
        cb();
      });
    });
Пример #12
0
      questions.ask('foo', function(err, answers) {
        if (err) return cb(err);
        assert.equal(answers.foo, 'bar');

        bddStdin('qux\n');
        questions.ask('foo', {force: true}, function(err, answers) {
          if (err) return cb(err);
          assert.equal(answers.foo, 'qux');
          intercepted();
          cb();
        });
      });
Пример #13
0
    createConfig(boilerplateFolderPath, () => {
      const ugenConfigPath = path.join(process.cwd(), 'ugen.config.js')
      const config = require(ugenConfigPath)
      const expectedAnswers = { ENV_HOME: 'AppHomeDir' }

      bddStdin('AppHomeDir\n')
      buildApp(config).then((answers) => {
        expect(answers).to.be.deep.equal(expectedAnswers)
        fs.removeSync(testFolderPath)
        done()
      }).catch((err) => {console.log(`Test error ${err}`)})
      process.chdir(currentCwd)
    })
Пример #14
0
  it('should not remove points with n-response', function() {
    expect(store(local).get('foo')).to.not.be.ok;
    localStore.set('foo', './test');

    expect(store(local).get('foo')).to.be.ok;

    stdin('n');
    return remove(local, 'foo', false, customConfig)
      .then(function(res) {
        expect(store(local).get('foo')).to.be.ok;
        expect(res).to.be.false;
      });
  });
Пример #15
0
 it('should generate `test` env when defined explicitly', function(cb) {
   bddStdin('\n', '\n', bddStdin.keys.down, bddStdin.keys.down, bddStdin.keys.down, ' ', '\n', '\n');
   app.generate(
     'babelrc',
     existscontains(
       '.babelrc',
       function(json) {
         return json.hasOwnProperty('env')
           && json.env.hasOwnProperty('test');
       },
       cb
     )
   );
 });
Пример #16
0
 it('should generate `presets` when defined explicitly', function(cb) {
   bddStdin('\n', ' ', '\n', '\n');
   app.generate(
     'babelrc',
     existscontains(
       '.babelrc',
       function(json) {
         return json.presets.indexOf('es2015') !== -1
           && json.presets.indexOf('es2016') !== -1
           && json.presets.indexOf('react') !== -1;
       },
       cb
     )
   );
 });
Пример #17
0
    it('rejected on no', function () {
      bddStdin('no\n')

      var rejected
      return confirm('is this ok?')
        .then(
          function () {
            la(false, 'invalid response, should be rejected on no')
          },
          function () {
            rejected = true
          }
        )
        .then(function () {
          la(rejected, 'response was never rejected')
        })
    })
Пример #18
0
    it('should force all questions to be asked', function(cb) {
      // var unhook = interception(/Name|Description/);

      app.question('name', {message: 'Name?'});
      app.question('desc', {message: 'Description?'});

      bddStdin('Brian Woodward', '\n', 'Foo', '\n');
      app.ask({force: true}, function(err, answers) {
        if (err) {
          cb(err);
          return;
        }
        assert.deepEqual(answers, {name: 'Brian Woodward', desc: 'Foo'});
        // unhook();
        cb();
      });
    });
Пример #19
0
    it('should not ask the same question more than once', function(cb) {
      var intercepted = interception('foo');

      questions.set('foo');
      bddStdin('bar\n');
      questions.ask('foo', function(err, answers) {
        if (err) return cb(err);
        assert.equal(answers.foo, 'bar');

        bddStdin('qux\n');
        questions.ask('foo', function(err, answers) {
          if (err) return cb(err);
          assert.equal(answers.foo, 'bar');
          intercepted();
          cb();
        });
      });
    });
Пример #20
0
    it('should always ask the question when force is true', function(cb) {
      var intercepted = interception('foo');

      questions.set('foo');
      bddStdin('bar\n');
      questions.ask('foo', function(err, answers) {
        if (err) return cb(err);
        assert.equal(answers.foo, 'bar');

        bddStdin('qux\n');
        questions.ask('foo', {force: true}, function(err, answers) {
          if (err) return cb(err);
          assert.equal(answers.foo, 'qux');
          intercepted();
          cb();
        });
      });
    });
    "Check that generates a lp-module properly": function (test) {
        var template_name = 'lp-module';

        test.expect(1);

        bddStdin('module-launchpad\n',
            'Module Launchpad Architecture\n', '1.0.0\n',
            'author@company.com\n', 'Y\n', 'N\n', 'a\n'
        );

        program.parse(['node', 'test', 'generate', template_name]);

        setTimeout(function () {
            dircompare
                .compare(path.join(__dirname, 'expected', 'module-launchpad'), path.join(__dirname, 'generated', 'module-launchpad'), dcOptions)
                .then(function (res) {
                    test.equals(res.distinct, 0, 'Both projects have the same content.');
                    test.done();
                })
                .catch(function (error) {
                    test.done();
                });
        }, timeout);
    },
Пример #22
0
 it('should run the `default` task when defined explicitly', function(cb) {
   bddStdin('\n', '\n', '\n');
   app.generate('babelrc:default', exists('.babelrc', cb));
 });
Пример #23
0
 it('passes extra value', () => {
   bddStdin('yes\n')
   return confirm('pass extra?', 42).then(value => {
     la(value === 42, 'expected extra value', value)
   })
 })
Пример #24
0
 it('default value is true', () => {
   bddStdin('\n') // note we don't actually enter anything
   return confirm({question: 'pass extra?', extra: 42}).then(value => {
     la(value === 42, 'expected extra value', value)
   })
 })
Пример #25
0
 it('passes extra value', () => {
   bddStdin('yes\n')
   return confirm({question: 'pass extra?', extra: 42}).then(value => {
     la(value === 42, 'expected extra value', value)
   })
 })
Пример #26
0
 beforeEach(function() {
   app.use(generator);
   bddStdin('\n', '\n', '\n');
 });
Пример #27
0
 it('should run the default task on the generator', function(cb) {
   bddStdin('\n', '\n', '\n');
   app.generate('babelrc', exists('.babelrc', cb));
 });
Пример #28
0
 it('should run the `babelrc` task', function(cb) {
   bddStdin('\n', '\n', '\n');
   app.generate('babelrc:babelrc', exists('.babelrc', cb));
 });
Пример #29
0
 app.on('ask', function() {
   bddStdin('foo', '\n');
 });
Пример #30
0
 beforeEach(function() {
   app.register('foo', function(foo) {
     foo.register('babelrc', generator);
   });
   bddStdin('\n', '\n', '\n');
 });