"use strict";

var _fs = require("fs");
var _path = require("path");
var _index = require("../index");
var _Generator = _interopRequireDefault(require("./Generator"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const fixtures = (0, _path.join)(__dirname, 'fixtures');
test('normal', async () => {
  const cwd = (0, _path.join)(fixtures, 'normal');
  const dist = (0, _path.join)(cwd, 'dist');
  _index.rimraf.sync(dist);
  const target = (0, _path.join)(dist, 'a.js');
  class NormalGenerator extends _Generator.default {
    prompting() {
      return [];
    }
    async writing() {
      this.copyTpl({
        context: {
          foo: 'bar'
        },
        target,
        templatePath: (0, _path.join)(cwd, 'a.js.tpl')
      });
      this.copyDirectory({
        context: {
          foo: 'bar'
        },
        path: (0, _path.join)(cwd, './dir'),
        target: (0, _path.join)(dist, './dir')
      });
    }
  }
  const g = new NormalGenerator({
    args: {
      _: [],
      $0: ''
    },
    baseDir: cwd
  });
  await g.run();
  expect((0, _fs.readFileSync)(target, 'utf-8').trim()).toEqual(`alert('bar');`);
  expect((0, _fs.readFileSync)((0, _path.join)(dist, './dir', 'a.js'), 'utf-8').trim()).toEqual(`alert('bar');`);
  expect((0, _fs.readFileSync)((0, _path.join)(dist, './dir', 'b.js'), 'utf-8').trim()).toEqual(`alert('abc');`);
});