<commit_before>'use strict';

var expect = require('chai').expect;
var fs = require('fs-extra');
var tmp = require('../../helpers/tmp');
var findBuildFile = require('../../../lib/utilities/find-build-file');

describe('find-build-file', function() {
  var tmpPath, tmpFilename, tmpFilePath;
  var currentWorkingDir = process.cwd();

  beforeEach(function() {
    tmpPath = process.cwd() + '/tmp/';
    tmpFilename = 'ember-cli-build.js';
    tmpFilePath = tmpPath + tmpFilename;
    return tmp.setup(tmpPath)
      .then(function() {
        process.chdir(tmpPath);
      });
  });

  afterEach(function() {
    delete require.cache[require.resolve(tmpFilePath)];
    return tmp.teardown(tmpPath).then(function() {
      process.chdir(currentWorkingDir);
    });
  });

  it('does not throws an error when the file is valid syntax', function() {
    fs.writeFileSync(tmpFilename, 'module.exports = function() {return {\'a\': \'A\', \'b\': \'B\'};}', { encoding: 'utf8' });

    expect(function() {
      findBuildFile(tmpFilename);
    }).to.not.throw();
  });

  it('throws an SyntaxError if the file contains a syntax mistake', function() {
    fs.writeFileSync(tmpFilename, 'module.exports = function() {return {\'a\': \'A\' \'b\': \'B\'};}', { encoding: 'utf8' });

    expect(function() {
      findBuildFile(tmpFilename);
    }).to.throw(SyntaxError, /Could not require '.*':/);
  });<commit_msg>tests/find-build-file: Use "./tmp/find-build-file-test" for tests<commit_after>'use strict';

var expect = require('chai').expect;
var fs = require('fs-extra');
var path = require('path');
var tmp = require('../../helpers/tmp');
var findBuildFile = require('../../../lib/utilities/find-build-file');

describe('find-build-file', function() {
  var tmpPath = 'tmp/find-build-file-test';
  var tmpFilename = 'ember-cli-build.js';

  beforeEach(function() {
    return tmp.setup(tmpPath)
      .then(function() {
        process.chdir(tmpPath);
      });
  });

  afterEach(function() {
    var tmpFilePath = path.resolve(tmpFilename);
    delete require.cache[require.resolve(tmpFilePath)];

    return tmp.teardown(tmpPath);
  });

  it('does not throws an error when the file is valid syntax', function() {
    fs.writeFileSync(tmpFilename, 'module.exports = function() {return {\'a\': \'A\', \'b\': \'B\'};}', { encoding: 'utf8' });

    expect(function() {
      findBuildFile(tmpFilename);
    }).to.not.throw();
  });

  it('throws an SyntaxError if the file contains a syntax mistake', function() {
    fs.writeFileSync(tmpFilename, 'module.exports = function() {return {\'a\': \'A\' \'b\': \'B\'};}', { encoding: 'utf8' });

    expect(function() {
      findBuildFile(tmpFilename);
    }).to.throw(SyntaxError, /Could not require '.*':/);
  });
{'fraction_non_alphanumeric': 0.2015982564475118, 'fraction_numerical': 0.001452960406828914, 'mean_word_length': 3.5296052631578947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7382091', 'n_tokens_mistral': 895, 'n_tokens_neox': 869, 'n_words': 188}