{"size": 1693, "ext": "js", "max_stars_repo_path": "test/validate-prop-types/dialog/final-jeopardy.spec.js", "max_stars_repo_name": "jmm/Jeopardy-Scorekeeper", "max_stars_repo_stars_event_min_datetime": "2015-12-12T19:34:23.000Z", "max_stars_repo_stars_event_max_datetime": "2016-12-24T18:25:43.000Z", "max_issues_repo_path": "test/validate-prop-types/dialog/final-jeopardy.spec.js", "max_issues_repo_name": "jmm/Jeopardy-Scorekeeper", "max_issues_repo_issues_event_min_datetime": "2022-02-15T01:08:24.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-15T01:08:24.000Z", "max_forks_repo_path": "test/validate-prop-types/dialog/final-jeopardy.spec.js", "max_forks_repo_name": "jmm/Jeopardy-Scorekeeper", "max_forks_repo_forks_event_min_datetime": "2015-07-31T17:56:34.000Z", "max_forks_repo_forks_event_max_datetime": "2015-07-31T17:56:34.000Z"}
{"max_stars_count": 2, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 22.5733333333, "max_line_length": 78, "alphanum_fraction": 0.6196101595}
"use strict";

var assign = Object.assign;
var Component = require("app/component/presentational/dialog/final-jeopardy");
var React = require("react");
var test = require("tape");
var util = require("util");
var validatePropTypes = require("validate-react-prop-types").validate;

var suiteDesc = "component/dialog/final-jeopardy : ";

function noop () {}

var baseProps = {
  players: [{}],
  num_tv_players: 3,
  sanitizeScore: noop,
  endGame: noop,
};

test(suiteDesc + "Valid props pass", function (t) {
  var props = [
    assign({}, baseProps),
  ];

  props.forEach(function (props) {
    t.ok(validatePropTypes(
      <Component {...props} />
    ).valid, "Validating " + util.inspect(props));
  });

  t.end();
});

test(suiteDesc + "Missing required props fail", function (t) {
  Object.keys(baseProps).forEach(function (key) {
    var props = assign({}, baseProps);
    delete props[key];

    var validation = validatePropTypes.quiet(<Component {...props} />, {
      whitelist: [key],
    });

    t.equal(
      validation.error.react.prop, key, `Errors on correct prop "${key}"`
    );
  });

  t.end();
});

test(suiteDesc + "Invalid props fail", function (t) {
  var invalidPropGroups = [
    {players: {}},
    {players: [1]},
    {num_tv_players: "3"},
    {sanitizeScore: false},
    {endGame: false},
  ];

  invalidPropGroups.forEach(invalidProps => {
    Object.entries(invalidProps).forEach(function ([key, value]) {
      const props = {[key]: value};

      const validation = validatePropTypes.quiet(<Component {...props} />, {
        whitelist: [key],
      }).error.react.prop

      t.equal(validation, key, `Invalid ${key} fails`);
    })
  });

  t.end();
});
