<commit_before>var os = require('os');
var fs = require('fs-extra');
var path = require('path');
var proxyquire = require('proxyquire');
var chai = require('chai');

var DotNetAnswersFixture = require('./fixtures/DotNetNoDescription');
var newCommand = proxyquire('../../bin/commands/new', {
    inquirer: {
        prompt: function(questions, callback) {
            return callback(DotNetAnswersFixture)
        }
    }
});

var appDir = path.join(__dirname, '..', '..', 'app');
var newCommandInstance = newCommand(appDir);

var date = new Date();
var timestamp = [date.getDate(), date.getDay(), date.getFullYear(), date.getHours(), date.getMinutes(), date.getMilliseconds()].join('');

var TEST_TEMP_DIR = path.join(os.tmpdir(), 'slate-' + timestamp);

chai.use(require('chai-fs'));
chai.should();

function newCommandSetup(done) {
    this.timeout(3000);

    fs.ensureDirSync(TEST_TEMP_DIR);
    process.chdir(TEST_TEMP_DIR);
    newCommandInstance.init();

    setTimeout(done, 2000);
}

function newCommandTearDown(done) {
    fs.removeSync(TEST_TEMP_DIR);
    done();
}

describe('As a user of the CLI', function() {

    describe('When the new command is used', function() {
        before(newCommandSetup);
        after(newCommandTearDown);

        it('should template the `creds.json` file with the correct contents', function() {
            var filePath = path.join(TEST_TEMP_DIR, '_config', 'creds.json');
            var actual = JSON.parse(fs.readFileSync(filePath, 'utf8'));
            var expected = {
                "Site": "test project",
                "Author": "test author",
                "packageName": "test-project"
            }

            filePath.should.be.a.file().with.json;

            actual.Site.should.equal(expected.Site);
            actual.Author.should.equal(expected.Author);
            actual.packageName.should.equal(expected.packageName);
        })
    })

    describe('When the new command is used for the project type: Dot NET', function() {
        before(newCommandSetup);
        after(newCommandTearDown);

        it('should populate the directory', function() {
            TEST_TEMP_DIR.should.be.a.directory().and.not.empty;
        })

        it('should not include the `views` directory', function() {
            var pathToTest = path.join(TEST_TEMP_DIR, 'views');

            pathToTest.should.not.be.a.path();
        })

        it('should not include the `release.js` gulp partial', function() {
            var pathToTest = path.join(TEST_TEMP_DIR, 'gulpTasks', 'release.js');

            pathToTest.should.not.be.a.path();
        })

    })
})<commit_msg>test: Add base test for static site new command<commit_after>var os = require('os');
var fs = require('fs-extra');
var path = require('path');
var proxyquire = require('proxyquire');
var chai = require('chai');

var DotNetAnswersFixture = require('./fixtures/DotNetNoDescription');
var StaticSiteAnswersFixture = require('./fixtures/StaticNoDescription');
var newCommandDotNet = proxyquire('../../bin/commands/new', {
    inquirer: {
        prompt: function(questions, callback) {
            return callback(DotNetAnswersFixture)
        }
    }
});

var newCommandStaticSite = proxyquire('../../bin/commands/new', {
    inquirer: {
        prompt: function(questions, callback) {
            return callback(StaticSiteAnswersFixture)
        }
    }
});

var appDir = path.join(__dirname, '..', '..', 'app');
var newCommandDotNetInstance = newCommandDotNet(appDir);
var newCommandStaticSiteInstance = newCommandStaticSite(appDir);

var date = new Date();
var timestamp = [date.getDate(), date.getDay(), date.getFullYear(), date.getHours(), date.getMinutes(), date.getMilliseconds()].join('');

var TEST_TEMP_DIR = path.join(os.tmpdir(), 'slate-' + timestamp);

chai.use(require('chai-fs'));
chai.should();

function changeToOsTempDir() {
    fs.ensureDirSync(TEST_TEMP_DIR);
    process.chdir(TEST_TEMP_DIR);
}

function newCommandDotNetSetup(done) {
    this.timeout(3000);

    changeToOsTempDir();
    newCommandDotNetInstance.init();

    setTimeout(done, 2000);
}

function newCommandStaticSiteSetup(done) {
    this.timeout(3000);

    changeToOsTempDir();
    newCommandStaticSiteInstance.init();

    setTimeout(done, 2000);
}

function newCommandTearDown(done) {
    fs.removeSync(TEST_TEMP_DIR);
    done();
}

describe('As a user of the CLI', function() {

    describe('When the new command is used', function() {
        before(newCommandDotNetSetup);
        after(newCommandTearDown);

        it('should template the `creds.json` file with the correct contents', function() {
            var filePath = path.join(TEST_TEMP_DIR, '_config', 'creds.json');
            var actual = JSON.parse(fs.readFileSync(filePath, 'utf8'));
            var expected = {
                "Site": "test project",
                "Author": "test author",
                "packageName": "test-project"
            }

            filePath.should.be.a.file().with.json;

            actual.Site.should.equal(expected.Site);
            actual.Author.should.equal(expected.Author);
            actual.packageName.should.equal(expected.packageName);
        })

        it('should template the `.slaterc` file with the correct contents', function() {
            var filePath = path.join(TEST_TEMP_DIR, '.slaterc');
            var packageJsonPath = path.join(TEST_TEMP_DIR, 'package.json');
            var packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
            var actual = JSON.parse(fs.readFileSync(filePath, 'utf8'));
            var expected = {
                "slateVersion": packageJson.version,
                "dateGenerated": [date.getDate(), date.getMonth() + 1, date.getFullYear()].join('/')
            }

            filePath.should.be.a.file().with.json;

            actual.slateVersion.should.equal(expected.slateVersion);
            actual.dateGenerated.should.equal(expected.dateGenerated);
        })

        it('should template the `package.json` file with the correct contents', function() {
            var filePath = path.join(TEST_TEMP_DIR, 'package.json');
            var actual = JSON.parse(fs.readFileSync(filePath, 'utf8'));
            var expected = {
                "name": "test-project",
                "description": ""
            }

            filePath.should.be.a.file().with.json;

            actual.name.should.equal(expected.name);
            actual.description.should.equal(expected.description);
        })
    })

    describe('When the new command is used for the project type: Static site', function() {
        before(newCommandStaticSiteSetup);
        after(newCommandTearDown);

        it('should populate the directory', function() {
            TEST_TEMP_DIR.should.be.a.directory().and.not.empty;
        })
    })

    describe('When the new command is used for the project type: Dot NET', function() {
        before(newCommandDotNetSetup);
        after(newCommandTearDown);

        it('should populate the directory', function() {
            TEST_TEMP_DIR.should.be.a.directory().and.not.empty;
        })

        it('should not include the `views` directory', function() {
            var pathToTest = path.join(TEST_TEMP_DIR, 'views');

            pathToTest.should.not.be.a.path();
        })

        it('should not include the `release.js` gulp partial', function() {
            var pathToTest = path.join(TEST_TEMP_DIR, 'gulpTasks', 'release.js');

            pathToTest.should.not.be.a.path();
        })

    })
})
{'fraction_non_alphanumeric': 0.1413057873129387, 'fraction_numerical': 0.003972983710766786, 'mean_word_length': 2.764705882352941, 'pattern_counts': {'":': 10, '<': 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': '2944059', 'n_tokens_mistral': 2253, 'n_tokens_neox': 2183, 'n_words': 440}