{"size": 1932, "ext": "js", "max_stars_repo_path": "test/server/utils/getColorsOption.test.js", "max_stars_repo_name": "noelebrun/webpack-dev-server", "max_stars_repo_stars_event_min_datetime": "2020-05-12T08:42:06.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-12T08:42:06.000Z", "max_issues_repo_path": "test/server/utils/getColorsOption.test.js", "max_issues_repo_name": "noelebrun/webpack-dev-server", "max_issues_repo_issues_event_min_datetime": "2021-06-13T16:04:35.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-25T03:16:10.000Z", "max_forks_repo_path": "test/server/utils/getColorsOption.test.js", "max_forks_repo_name": "noelebrun/webpack-dev-server", "max_forks_repo_forks_event_min_datetime": "2021-06-16T10:14:25.000Z", "max_forks_repo_forks_event_max_datetime": "2021-06-16T10:14:25.000Z"}
{"max_stars_count": 1, "max_issues_count": 102, "max_forks_count": 1, "avg_line_length": 19.9175257732, "max_line_length": 91, "alphanum_fraction": 0.4456521739}
'use strict';

const getColorsOption = require('../../../lib/utils/getColorsOption');

describe('getColorsOption', () => {
  it('should return false for empty config array', () => {
    expect(getColorsOption([])).toEqual(false);
  });

  it('should return false for config array with no colors option', () => {
    expect(
      getColorsOption([
        {
          entry: './index.js',
        },
      ])
    ).toEqual(false);
  });

  it('should return false for config array with stats string but no colors option', () => {
    expect(
      getColorsOption([
        {
          stats: 'verbose',
        },
      ])
    ).toEqual(false);
  });

  it('should return false for config array with stats object but no colors option', () => {
    expect(
      getColorsOption([
        {
          stats: {
            cached: false,
          },
        },
      ])
    ).toEqual(false);
  });

  it('should return false for first stats option with no colors option', () => {
    expect(
      getColorsOption([
        {
          stats: {
            cached: false,
          },
        },
        {
          stats: {
            colors: true,
          },
        },
      ])
    ).toEqual(false);
  });

  it('should return true for first stats option that has true colors option', () => {
    expect(
      getColorsOption([
        {
          stats: {
            colors: true,
          },
        },
        {
          stats: {
            cached: false,
          },
        },
      ])
    ).toEqual(true);
  });

  it('should return object for first stats option that has object colors option', () => {
    expect(
      getColorsOption([
        {
          stats: {
            colors: {
              green: '\u001b[32m',
            },
          },
        },
        {
          stats: {
            cached: false,
          },
        },
      ])
    ).toEqual({
      green: '\u001b[32m',
    });
  });
});
