<commit_before>/* global describe, it, beforeEach */

'use strict';

var path = require('path'),
    fs = require('fs'),
    ncp = require('ncp').ncp,
    rimraf = require('rimraf'),
    expect = require('chai').expect;

describe('chnpm', function () {

    beforeEach(function (done) {
        delete require.cache[require.resolve('..')];
        process.env.HOME = 'temp';
        if (fs.existsSync('temp')) { rimraf.sync('temp'); }
        ncp(path.join(__dirname, 'fixtures'), 'temp', done);
    });

    it('should list configs', function (done) {
        var chnpm = require('..');
        chnpm.on('info', function (message) {
            expect(message).to.contain('current: <EMAIL>');
            expect(message).to.contain('repo: <EMAIL>');
            done();
        });
        chnpm.listRcs();
    });

    it('should save configs', function (done) {
        var chnpm = require('..');
        chnpm.on('info', function (message) {
            expect(message).to.contain('Saved <EMAIL> as .new.npmrc');
            expect(fs.existsSync('temp/.new.npmrc')).to.be.true;
            done();
        });
        chnpm.saveRc('new');
    });

    it('should not overwrite configs', function (done) {
        var chnpm = require('..');
        chnpm.on('error', function (message) {
            expect(message).to.contain('File `temp/.repo.npmrc` already exist!');
            done();
        });
        chnpm.saveRc('repo');
    });

    it('should switch configs', function (done) {
        var chnpm = require('..');
        chnpm.on('info', function (message) {
            expect(message).to.contain('Switched to <EMAIL>');
            done();
        });
        chnpm.setRc('repo');
    });

    it('should warn about non-existent configs', function (done) {
        var chnpm = require('..');
        chnpm.on('info', function (message) {
            expect(message).to.contain('File `temp/.unknown.npmrc` not found!');
            done();
        });
        chnpm.setRc('unknown');
    });
});
<commit_msg>Fixup test<commit_after>/* global describe, it, beforeEach */

'use strict';

var path = require('path'),
    fs = require('fs'),
    ncp = require('ncp').ncp,
    rimraf = require('rimraf'),
    expect = require('chai').expect;

describe('chnpm', function () {

    beforeEach(function (done) {
        delete require.cache[require.resolve('..')];
        process.env.HOME = 'temp';
        if (fs.existsSync('temp')) { rimraf.sync('temp'); }
        ncp(path.join(__dirname, 'fixtures'), 'temp', done);
    });

    it('should list configs', function (done) {
        var chnpm = require('..');
        chnpm.on('info', function (message) {
            expect(message).to.contain('repo: <EMAIL>');
            done();
        });
        chnpm.listRcs();
    });

    it('should save configs', function (done) {
        var chnpm = require('..');
        chnpm.on('info', function (message) {
            expect(message).to.contain('Saved <EMAIL>@<EMAIL> as .new.npmrc');
            expect(fs.existsSync('temp/.new.npmrc')).to.be.true;
            done();
        });
        chnpm.saveRc('new');
    });

    it('should not overwrite configs', function (done) {
        var chnpm = require('..');
        chnpm.on('error', function (message) {
            expect(message).to.contain('File `temp/.repo.npmrc` already exist!');
            done();
        });
        chnpm.saveRc('repo');
    });

    it('should switch configs', function (done) {
        var chnpm = require('..');
        chnpm.on('info', function (message) {
            expect(message).to.contain('Switched to <EMAIL>');
            done();
        });
        chnpm.setRc('repo');
    });

    it('should warn about non-existent configs', function (done) {
        var chnpm = require('..');
        chnpm.on('info', function (message) {
            expect(message).to.contain('File `temp/.unknown.npmrc` not found!');
            done();
        });
        chnpm.setRc('unknown');
    });
});

{'fraction_non_alphanumeric': 0.19148936170212766, 'fraction_numerical': 0.0, 'mean_word_length': 2.207062600321027, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1831143', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1215, 'n_words': 241}