<commit_before>/* Copyright (C) 2017 Canonical Ltd. */
'use strict';

const React = require('react');

const HeaderLogo = require('./header-logo');
const SvgIcon = require('../svg-icon/svg-icon');

const jsTestUtils = require('../../utils/component-test-utils');

describe('HeaderLogo', function() {

  it('renders for gisf', () => {
    const showProfile = sinon.stub();
    const renderer = jsTestUtils.shallowRender(
      <HeaderLogo
        gisf={true}
        homePath="/"
        showProfile={showProfile} />, true);
    const output = renderer.getRenderOutput();
    const expected = (
      <a href="/" onClick={showProfile} role="button" title="Home">
        <SvgIcon className="svg-icon"
          height="35"
          name="juju-logo" width="90" />
      </a>);
    expect(output).toEqualJSX(expected);
  });

  it('renders for gijoe', () => {
    const showProfile = sinon.stub();
    const renderer = jsTestUtils.shallowRender(
      <HeaderLogo
        gisf={false}
        homePath="/u/hatch"
        showProfile={showProfile} />, true);
    const output = renderer.getRenderOutput();
    const expected = (
      <a href="/u/hatch" onClick={showProfile} role="button" title="Home">
        <SvgIcon className="svg-icon"
          height="35"
          name="juju-logo" width="90" />
      </a>);
    expect(output).toEqualJSX(expected);
  });

  it('calls showProfile on click in gijoe', () => {
    const showProfile = sinon.stub();
    const preventDefault = sinon.stub();
    const renderer = jsTestUtils.shallowRender(
      <HeaderLogo
        gisf={false}
        homePath="/u/hatch"
        showProfile={showProfile} />, true);
    const output = renderer.getRenderOutput();
    // Call the click handler
    output.props.onClick({preventDefault});
    assert.equal(preventDefault.callCount, 1);
    assert.equal(showProfile.callCount, 1);
  });

  it('does not call showProfile on click in gisf', () => {
    const showProfile = sinon.stub();
    const preventDefault = sinon.stub();
    const renderer = jsTestUtils.shallowRender(
      <HeaderLogo
        gisf={true}
        homePath="/u/hatch"
        showProfile={showProfile} />, true);
    const output = renderer.getRenderOutput();
    // Call the click handler
    output.props.onClick({preventDefault});
    assert.equal(preventDefault.callCount, 0);
    assert.equal(showProfile.callCount, 0);
  });
});<commit_msg>Update header logo tests to use enzyme.<commit_after>/* Copyright (C) 2017 Canonical Ltd. */
'use strict';

const React = require('react');
const enzyme = require('enzyme');

const HeaderLogo = require('./header-logo');
const SvgIcon = require('../svg-icon/svg-icon');

describe('HeaderLogo', function() {

  const renderComponent = (options = {}) => enzyme.shallow(
    <HeaderLogo
      gisf={options.gisf === undefined ? true : options.gisf}
      homePath={options.homePath || '/'}
      showProfile={options.showProfile || sinon.stub()} />
  );

  it('renders', () => {
    const wrapper = renderComponent();
    const expected = (
      <a href="/"
        onClick={wrapper.prop('onClick')}
        role="button"
        title="Home">
        <SvgIcon className="svg-icon"
          height="35"
          name="juju-logo" width="90" />
      </a>);
    assert.compareJSX(wrapper, expected);
  });

  it('calls showProfile on click in gijoe', () => {
    const showProfile = sinon.stub();
    const preventDefault = sinon.stub();
    const wrapper = renderComponent({
      gisf: false,
      showProfile
    });
    // Call the click handler
    wrapper.props().onClick({preventDefault});
    assert.equal(preventDefault.callCount, 1);
    assert.equal(showProfile.callCount, 1);
  });

  it('does not call showProfile on click in gisf', () => {
    const showProfile = sinon.stub();
    const preventDefault = sinon.stub();
    const wrapper = renderComponent({ showProfile });
    // Call the click handler
    wrapper.props().onClick({preventDefault});
    assert.equal(preventDefault.callCount, 0);
    assert.equal(showProfile.callCount, 0);
  });
});
{'fraction_non_alphanumeric': 0.15842558425584255, 'fraction_numerical': 0.006888068880688807, 'mean_word_length': 3.066, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1373930', 'n_tokens_mistral': 1241, 'n_tokens_neox': 1224, 'n_words': 263}