{"size": 1793, "ext": "js", "max_stars_repo_path": "test/lib/config.js", "max_stars_repo_name": "SlNPacifist/hermione-profiler", "max_stars_repo_stars_event_min_datetime": "2018-02-01T08:13:16.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-15T10:21:15.000Z", "max_issues_repo_path": "test/lib/config.js", "max_issues_repo_name": "SlNPacifist/hermione-profiler", "max_issues_repo_issues_event_min_datetime": "2017-09-27T10:46:14.000Z", "max_issues_repo_issues_event_max_datetime": "2021-06-23T14:34:54.000Z", "max_forks_repo_path": "test/lib/config.js", "max_forks_repo_name": "SlNPacifist/hermione-profiler", "max_forks_repo_forks_event_min_datetime": "2022-03-19T07:26:36.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-19T07:26:36.000Z"}
{"max_stars_count": 3, "max_issues_count": 9, "max_forks_count": 1, "avg_line_length": 28.9193548387, "max_line_length": 78, "alphanum_fraction": 0.5331846068}
'use strict';

const parseConfig = require('../../lib/config');

describe('config', () => {
    beforeEach(function() {
        this.oldArgv = process.argv;
    });

    afterEach(function() {
        process.argv = this.oldArgv;

        delete process.env['hermione_profiler_enabled'];
        delete process.env['hermione_profiler_path'];
    });

    describe('enabled', () => {
        it('should be true by default', () => {
            assert.isTrue(parseConfig({}).enabled);
        });

        it('should be set from configuration', () => {
            assert.isFalse(parseConfig({enabled: false}).enabled);
        });

        it('should be set from cli', () => {
            process.argv = process.argv.concat('--profiler-enabled', 'false');

            assert.isFalse(parseConfig({}).enabled);
        });

        it('should be set from environment variable', () => {
            process.env['hermione_profiler_enabled'] = 'false';
            console.log(process.argv);

            assert.isFalse(parseConfig({}).enabled);
        });
    });

    describe('path', () => {
        it('should be "hermione-profiler" by default', () => {
            assert.equal(parseConfig({}).path, 'hermione-profiler');
        });

        it('should be set from configuration', () => {
            assert.equal(parseConfig({path: 'some/path'}).path, 'some/path');
        });

        it('should be set from cli', () => {
            process.argv = process.argv.concat('--profiler-path', 'new/path');

            assert.equal(parseConfig({}).path, 'new/path');
        });

        it('should be set from environment variable', () => {
            process.env['hermione_profiler_path'] = 'some/path';

            assert.equal(parseConfig({}).path, 'some/path');
        });
    });
});
