<commit_before>const shell = require('shelljs');
const fs = require('fs');
const internalTasks = require('@bolt/build-tools/tasks/internal-tasks');
const dirTree = require('directory-tree');

const dirs = {
  global:
    'packages/generators/yeoman-create-component/generators/component/tmp',
  js: 'test.js',
  scss: 'test.scss',
  test: 'index.js',
  package: 'package.json',
  readme: 'README.md',
  schema: 'test.schema.yml',
  boltrc: '.boltrc.js',
};

dirs.component = `${dirs.global}/packages/components/bolt-test`;
dirs.src = `${dirs.component}/src`;
dirs.testing = `${dirs.component}/__tests__`;
dirs.patternLab = `${dirs.global}/docs-site/src/pages/pattern-lab/_patterns/02-components/test/00-test-docs.twig`;

describe('Yeoman component generator', () => {
  beforeAll(async () => {
    shell.exec(`rm -rf ${dirs.global}`);
    shell.exec('yarn run cc -N Test -D "Test Description" -T');
  });

  afterAll(async () => {
    await internalTasks.clean(dirs.global);
  });

  test('pattern lab file exist', async () => {
    const results = fs.readFileSync(dirs.patternLab, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('JS file exist', async () => {
    const results = fs.readFileSync(`${dirs.src}/${dirs.js}`, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('SCSS file exist', async () => {
    const results = fs.readFileSync(`${dirs.src}/${dirs.scss}`, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('tests file exist', async () => {
    const results = fs.readFileSync(`${dirs.testing}/${dirs.test}`, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('index JS file exist', async () => {
    const results = fs.readFileSync(`${dirs.component}/index.js`, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('index SCSS file exist', async () => {
    const results = fs.readFileSync(`${dirs.component}/index.scss`, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('package.json file exist', async () => {
    const results = fs.readFileSync(
      `${dirs.component}/${dirs.package}`,
      'utf8',
    );

    expect(results).toMatchSnapshot();
  });

  test('readme file exist', async () => {
    const results = fs.readFileSync(`${dirs.component}/${dirs.readme}`, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('schema file exist', async () => {
    const results = fs.readFileSync(`${dirs.component}/${dirs.schema}`, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('bolt package.json file is updated', async () => {
    const results = fs.readFileSync(`${dirs.global}/${dirs.package}`, 'utf8');

    expect(results.includes('@bolt/components-test')).toBe(true);
  });

  test('.boltrc.js is updated', async () => {
    const results = fs.readFileSync(`${dirs.global}/${dirs.boltrc}`, 'utf8');

    expect(results.includes('@bolt/components-test')).toBe(true);
  });

  test('folder structure of component package is correct', async () => {
    const results = dirTree(dirs.global);
    const stringifyResult = JSON.stringify(results);

    expect(stringifyResult).toMatchSnapshot();
  });
});
<commit_msg>update folder structure test<commit_after>const shell = require('shelljs');
const fs = require('fs');
const internalTasks = require('@bolt/build-tools/tasks/internal-tasks');
const dir = require('node-dir');

const dirs = {
  global:
    'packages/generators/yeoman-create-component/generators/component/tmp',
  js: 'test.js',
  scss: 'test.scss',
  test: 'index.js',
  package: 'package.json',
  readme: 'README.md',
  schema: 'test.schema.yml',
  boltrc: '.boltrc.js',
};

dirs.component = `${dirs.global}/packages/components/bolt-test`;
dirs.src = `${dirs.component}/src`;
dirs.testing = `${dirs.component}/__tests__`;
dirs.patternLab = `${dirs.global}/docs-site/src/pages/pattern-lab/_patterns/02-components/test/00-test-docs.twig`;

describe('Yeoman component generator', () => {
  beforeAll(async () => {
    shell.exec(`rm -rf ${dirs.global}`);
    shell.exec('yarn run cc -N Test -D "Test Description" -T');
  });

  afterAll(async () => {
    await internalTasks.clean(dirs.global);
  });

  test('pattern lab file exist', async () => {
    const results = fs.readFileSync(dirs.patternLab, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('JS file exist', async () => {
    const results = fs.readFileSync(`${dirs.src}/${dirs.js}`, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('SCSS file exist', async () => {
    const results = fs.readFileSync(`${dirs.src}/${dirs.scss}`, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('tests file exist', async () => {
    const results = fs.readFileSync(`${dirs.testing}/${dirs.test}`, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('index JS file exist', async () => {
    const results = fs.readFileSync(`${dirs.component}/index.js`, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('index SCSS file exist', async () => {
    const results = fs.readFileSync(`${dirs.component}/index.scss`, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('package.json file exist', async () => {
    const results = fs.readFileSync(
      `${dirs.component}/${dirs.package}`,
      'utf8',
    );

    expect(results).toMatchSnapshot();
  });

  test('readme file exist', async () => {
    const results = fs.readFileSync(`${dirs.component}/${dirs.readme}`, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('schema file exist', async () => {
    const results = fs.readFileSync(`${dirs.component}/${dirs.schema}`, 'utf8');

    expect(results).toMatchSnapshot();
  });

  test('bolt package.json file is updated', async () => {
    const results = fs.readFileSync(`${dirs.global}/${dirs.package}`, 'utf8');

    expect(results.includes('@bolt/components-test')).toBe(true);
  });

  test('.boltrc.js is updated', async () => {
    const results = fs.readFileSync(`${dirs.global}/${dirs.boltrc}`, 'utf8');

    expect(results.includes('@bolt/components-test')).toBe(true);
  });

  test('folder structure of component package is correct', async () => {
    const results = await dir.files(dirs.global, { sync: true });

    expect(results).toMatchSnapshot();
  });
});

{'fraction_non_alphanumeric': 0.20467648942985267, 'fraction_numerical': 0.004804612427930814, 'mean_word_length': 4.040355125100888, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4632640', 'n_tokens_mistral': 2116, 'n_tokens_neox': 2059, 'n_words': 357}