// jshint esversion: 6
'use strict';

import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import React from 'react';
import PropTypes from 'prop-types';
import { mount } from '../../../build/enzyme';
import { CheckboxGroup } from './CheckboxGroup';
import { Checkbox } from './Checkbox';
describe('CheckboxGroup', function () {
  var cbGroup = function cbGroup(props) {
    var values = props.values,
        rest = _objectWithoutPropertiesLoose(props, ["values"]);

    return React.createElement(CheckboxGroup, _extends({
      name: "group",
      value: values
    }, rest), Object.keys(values).map(function (key) {
      return React.createElement(Checkbox, {
        key: key,
        name: key
      });
    }));
  };

  cbGroup.propTypes = {
    values: PropTypes.object.isRequired
  };
  describe('returns main checkbox value (based on children)', function () {
    it('true if all nested checkboxes have truthy value', function () {
      var values = {
        a: true,
        b: true
      };
      var wrapper = mount(cbGroup({
        values: values
      }));
      expect(wrapper.instance().getMainCheckboxValue()).toBe(true);
    });
    it('false if all nested checkboxes have falsy value', function () {
      var values = {
        a: false,
        b: false
      };
      var wrapper = mount(cbGroup({
        values: values
      }));
      expect(wrapper.instance().getMainCheckboxValue()).toBe(false);
    });
    it('null if nested checkboxes have both truthy and false value', function () {
      var values = {
        a: true,
        b: false
      };
      var wrapper = mount(cbGroup({
        values: values
      }));
      expect(wrapper.instance().getMainCheckboxValue()).toBe(null);
    });
  });
});