How to use the yeoman-test/lib/adapter.TestAdapter function in yeoman-test

To help you get started, we’ve selected a few yeoman-test examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yeoman / generator / test / install.js View on Github external
beforeEach(() => {
    this.env = yeoman.createEnv([], {}, new TestAdapter());
    const Dummy = class extends Base {
      exec() {}
    };
    this.env.registerStub(Dummy, 'dummy');
    this.dummy = this.env.create('dummy');

    // Keep track of all commands executed by spawnCommand.
    this.spawnCommandStub = sinon.stub(this.dummy, 'spawnCommand');
    this.spawnCommandStub.returns(asyncStub);
  });
github yeoman / generator / test / conflicter.js View on Github external
it('shows old content for deleted text files', done => {
      const testAdapter = new TestAdapter({ action: 'diff' });
      const conflicter = new Conflicter(testAdapter);
      const _prompt = testAdapter.prompt.bind(testAdapter);
      const promptStub = sinon
        .stub(testAdapter, 'prompt')
        .callsFake((prompts, resultHandler) => {
          if (promptStub.calledTwice) {
            const stubbedResultHandler = result => {
              result.action = 'write';
              return resultHandler(result);
            };

            return _prompt(prompts, stubbedResultHandler);
          }

          return _prompt(prompts, resultHandler);
        });
github yeoman / generator / test / base.js View on Github external
it('allow skipping file writes to disk', function() {
      const action = { action: 'skip' };
      const filepath = path.join(__dirname, '/fixtures/conflict.js');
      assert(fs.existsSync(filepath));

      this.TestGenerator.prototype.writing = function() {
        this.fs.write(filepath, 'some new content');
      };

      const env = yeoman.createEnv([], { 'skip-install': true }, new TestAdapter(action));
      const testGen = new this.TestGenerator([], {
        resolved: 'generator/app/index.js',
        namespace: 'dummy',
        env
      });

      return testGen.run().then(() => {
        assert.equal(fs.readFileSync(filepath, 'utf8'), 'var a = 1;\n');
      });
    });
github yeoman / generator / test / conflicter.js View on Github external
it('skip deleted file with dryRun', function(done) {
      const conflicter = new Conflicter(new TestAdapter(), false, {
        dryRun: true
      });
      conflicter.collision(
        {
          path: path.join(__dirname, 'fixtures/foo.js'),
          contents: null
        },
        status => {
          assert.equal(status, 'skip');
          done();
        }
      );
    });
github yeoman / generator / test / base.js View on Github external
it('emits the series of event on a specific generator', function(done) {
      const angular = new this.Generator([], {
        env: yeoman.createEnv([], {}, new TestAdapter()),
        resolved: __filename,
        'skip-install': true
      });

      const lifecycle = [
        'run',
        'method:createSomething',
        'method:createSomethingElse',
        'end'
      ];

      function assertEvent(e) {
        return function() {
          assert.equal(e, lifecycle.shift());

          if (e === 'end') {
github yeoman / generator / test / invoke.js View on Github external
beforeEach(function () {
    this.env = yeoman.createEnv([], {}, new TestAdapter());
    this.Generator = generators.Base.extend({
      exec: function () {}
    });
    this.gen = new this.Generator({
      namespace: 'foo:lab',
      resolved: 'path/',
      env: this.env,
      'skip-install': true
    });

    this.SubGen = generators.Base.extend({
      exec: function () {
        this.stubGenRan = true;
      }
    });
github yeoman / generator / test / remote.js View on Github external
beforeEach(function () {
    this.env = yeoman.createEnv([], {}, new TestAdapter());
    var Dummy = generators.Base.extend({
      exec: sinon.spy()
    });
    this.env.registerStub(Dummy, 'dummy');
    this.dummy = this.env.create('dummy');
    nock('https://github.com')
      .get('/yeoman/generator/archive/master.tar.gz')
      .replyWithFile(200, path.join(__dirname, 'fixtures/testRemoteFile.tar.gz'));
  });
github yeoman / generator / test / fetch.js View on Github external
beforeEach(function () {
    this.dummy = new generators.Base({
      env: yeoman.createEnv([], {}, new TestAdapter()),
      resolved: 'test:fetch'
    });
  });
github yeoman / generator / test / actions.js View on Github external
beforeEach(function () {
    var env = this.env = generators([], {}, new TestAdapter());
    var Dummy = generators.Base.extend({
      exec: function () {}
    });
    env.registerStub(Dummy, 'dummy');
    this.dummy = env.create('dummy');
    this.fixtures = path.join(__dirname, 'fixtures');
    this.dummy.sourceRoot(this.fixtures);
    this.dummy.foo = 'bar';
  });