{"size": 1328, "ext": "js", "max_stars_repo_path": "test/node-unit/cli/run-helpers.spec.js", "max_stars_repo_name": "cspotcode/mocha", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/node-unit/cli/run-helpers.spec.js", "max_issues_repo_name": "cspotcode/mocha", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/node-unit/cli/run-helpers.spec.js", "max_forks_repo_name": "cspotcode/mocha", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.0392156863, "max_line_length": 71, "alphanum_fraction": 0.5030120482}
'use strict';

const {validatePlugin, list} = require('../../../lib/cli/run-helpers');
const {createSandbox} = require('sinon');

describe('cli "run" command', function() {
  let sandbox;

  beforeEach(function() {
    sandbox = createSandbox();
  });

  afterEach(function() {
    sandbox.restore();
  });

  describe('helpers', function() {
    describe('validatePlugin()', function() {
      it('should disallow an array of module names', function() {
        expect(
          () => validatePlugin({foo: ['bar']}, 'foo'),
          'to throw',
          TypeError
        );
      });
    });

    describe('list()', function() {
      describe('when provided a flat array', function() {
        it('should return a flat array', function() {
          expect(list(['foo', 'bar']), 'to equal', ['foo', 'bar']);
        });
      });
      describe('when provided a nested array', function() {
        it('should return a flat array', function() {
          expect(list([['foo', 'bar'], 'baz']), 'to equal', [
            'foo',
            'bar',
            'baz'
          ]);
        });
      });
      describe('when given a comma-delimited string', function() {
        it('should return a flat array', function() {
          expect(list('foo,bar'), 'to equal', ['foo', 'bar']);
        });
      });
    });
  });
});
