<commit_before>import path from 'path';

import assert from 'yeoman-assert';
import helpers from 'yeoman-test';

beforeAll(() =>
  helpers.run(path.join(__dirname, '../app')).inTmpDir().withPrompts({
    moduleName: 'bunny module',
    description: 'as cute as bunny',
    githubUsername: 'bunny',
    website: 'www.wewww.com',
    name: 'yo',
    email: '<EMAIL>',
  })
);

describe('generator', () => {
  it('can be required without throwing', () => {
    const app = require('./'); // eslint-disable-line
    assert(app);
  });

  it('renames files', () => {
    assert.file([
      '.all-contributorsrc',
      '.babelrc',
      '.editorconfig',
      '.eslintignore',
      '.eslintrc.json',
      '.flowconfig',
      '.gitattributes',
      '.github/issue_template.md',
      '.github/pull_request_template.md',
      '.gitignore',
      '.npmrc',
      '.travis.yml',
      'package.json',
      'src/index.test.js',
    ]);
    assert.noFile('yo-rc.json');
  });
});

describe('templating', () => {
  it('fills package.json with correct informations', () => {
    assert.JSONFileContent('package.json', {
      name: 'bunny-module',
      description: 'as cute as bunny',
      repository: {
        type: 'git',
        url: 'git+https://github.com/bunny/bunny-module.git',
      },
      author: {
        name: 'yo',
        email: '<EMAIL>',
        url: 'www.wewww.com',
      },
    });
  });

  describe('readme.md', () => {
    it('fills the title & description', () => {
      assert.fileContent('readme.md', '# bunny-module');
      assert.fileContent('readme.md', '> as cute as bunny');
    });

    describe('badges', () => {
      it('package version', () => {
        assert.fileContent(
          'readme.md',
          '[![npm](https://img.shields.io/npm/v/bunny-module.svg?style=flat-square)](https://www.npmjs.com/package/bunny-module)'
        );
      });

      it('download stats', () => {
        assert.fileContent(
          'readme.md',
          '[![npm](https://img.shields.io/npm/dt/bunny-module.svg?style=flat-square)](https://npm-stat.com/charts.html?package=bunny-module&from=2016-04-01)'
        );
      });

      it('build status', () => {
        assert.fileContent(<commit_msg>test: group `package.json` specs<commit_after>import path from 'path';

import assert from 'yeoman-assert';
import helpers from 'yeoman-test';

beforeAll(() =>
  helpers.run(path.join(__dirname, '../app')).inTmpDir().withPrompts({
    moduleName: 'bunny module',
    description: 'as cute as bunny',
    githubUsername: 'bunny',
    website: 'www.wewww.com',
    name: 'yo',
    email: '<EMAIL>',
  })
);

describe('generator', () => {
  it('can be required without throwing', () => {
    const app = require('./'); // eslint-disable-line
    assert(app);
  });

  it('renames files', () => {
    assert.file([
      '.all-contributorsrc',
      '.babelrc',
      '.editorconfig',
      '.eslintignore',
      '.eslintrc.json',
      '.flowconfig',
      '.gitattributes',
      '.github/issue_template.md',
      '.github/pull_request_template.md',
      '.gitignore',
      '.npmrc',
      '.travis.yml',
      'package.json',
      'src/index.test.js',
    ]);
    assert.noFile('yo-rc.json');
  });
});

describe('templating', () => {
  describe('package.json', () => {
    it('fills with correct informations', () => {
      assert.fileContent('package.json', /"name": "bunny-module",/);
      assert.fileContent('package.json', /"description": "as cute as bunny",/);
      assert.JSONFileContent('package.json', {
        repository: {
          type: 'git',
          url: 'git+https://github.com/bunny/bunny-module.git',
        },
        author: {
          name: 'yo',
          email: '<EMAIL>',
          url: 'www.wewww.com',
        },
      });
    });
  });

  describe('readme.md', () => {
    it('fills the title & description', () => {
      assert.fileContent('readme.md', '# bunny-module');
      assert.fileContent('readme.md', '> as cute as bunny');
    });

    describe('badges', () => {
      it('package version', () => {
        assert.fileContent(
          'readme.md',
          '[![npm](https://img.shields.io/npm/v/bunny-module.svg?style=flat-square)](https://www.npmjs.com/package/bunny-module)'
        );
      });

      it('download stats', () => {
        assert.fileContent(
          'readme.md',
          '[![npm](https://img.shields.io/npm/dt/bunny-module.svg?style=flat-square)](https://npm-stat.com/charts.html?package=bunny-module&from=2016-04-01)'
        );
      });

      it('build status', () => {
        assert.fileContent(
{'fraction_non_alphanumeric': 0.20725613730175974, 'fraction_numerical': 0.003475993917010645, 'mean_word_length': 2.438386855862584, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 34, 'https://': 10, 'lorem ipsum': 0, 'www.': 10, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1827044', 'n_tokens_mistral': 1587, 'n_tokens_neox': 1506, 'n_words': 228}