<commit_before>import React from 'react';
import { shallow } from 'enzyme';
import { theme as defaultTheme, withTheme } from '../src';

describe('withTheme', () => {
  test('it should be a fn', () => {
    expect(withTheme).toBeInstanceOf(Function);
  });

  test('it should return a fn', () => {
    expect(withTheme()).toBeInstanceOf(Function);
  });
});

describe('HOC', () => {
  test('it has a wrapped displayName', () => {
    function MyComponent() { return null; }
    function WithDisplayName() { return null; }
    WithDisplayName.displayName = 'MyDisplayName';

    const hoc1 = withTheme({})(MyComponent);
    expect(hoc1.displayName).toBe('withTheme(MyComponent)');

    const hoc2 = withTheme({})(WithDisplayName);
    expect(hoc2.displayName).toBe('withTheme(MyDisplayName)');
  });

  test('it passes the theme prop to the wrapped component', () => {
    const testTheme = { my: 'theme' };
    function MyComponent({ theme }) {
      expect(theme).toBe(testTheme);
      return null;
    }
    const HOC = withTheme(testTheme)(MyComponent);
    shallow(<HOC />).dive();
  });

  test('it passes the default theme when no theme is passed', () => {
    function MyComponent({ theme }) {
      expect(theme).toEqual(defaultTheme);
      return null;
    }
    const HOC = withTheme()(MyComponent);
    shallow(<HOC />).dive();
  });
});<commit_msg>[xy-chart][withTheme][tests] add override theme test<commit_after>import React from 'react';
import { shallow } from 'enzyme';
import { theme as defaultTheme, withTheme } from '../src';

describe('withTheme', () => {
  test('it should be a fn', () => {
    expect(withTheme).toBeInstanceOf(Function);
  });

  test('it should return a fn', () => {
    expect(withTheme()).toBeInstanceOf(Function);
  });
});

describe('HOC', () => {
  test('it has a wrapped displayName', () => {
    function MyComponent() { return null; }
    function WithDisplayName() { return null; }
    WithDisplayName.displayName = 'MyDisplayName';

    const hoc1 = withTheme({})(MyComponent);
    expect(hoc1.displayName).toBe('withTheme(MyComponent)');

    const hoc2 = withTheme({})(WithDisplayName);
    expect(hoc2.displayName).toBe('withTheme(MyDisplayName)');
  });

  test('it passes the theme prop to the wrapped component', () => {
    const testTheme = { my: 'theme' };
    function MyComponent({ theme }) {
      expect(theme).toBe(testTheme);
      return null;
    }
    const HOC = withTheme(testTheme)(MyComponent);
    shallow(<HOC />).dive();
  });

  test('it passes the default theme when no theme is passed', () => {
    function MyComponent({ theme }) {
      expect(theme).toBe(defaultTheme);
      return null;
    }
    const HOC = withTheme()(MyComponent);
    shallow(<HOC />).dive();
  });

  test('it allows theme to be overridden', () => {
    const overrideTheme = { override: 'theme' };
    function MyComponent() { return null; }
    const HOC = withTheme()(MyComponent);

    let wrapper = shallow(<HOC />);
    expect(wrapper.find(MyComponent).prop('theme')).toBe(defaultTheme);

    wrapper = shallow(<HOC theme={overrideTheme} />);
    expect(wrapper.find(MyComponent).prop('theme')).toBe(overrideTheme);
  });
});
{'fraction_non_alphanumeric': 0.1725219573400251, 'fraction_numerical': 0.002509410288582183, 'mean_word_length': 3.846504559270517, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 24, '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': '4656245', 'n_tokens_mistral': 973, 'n_tokens_neox': 940, 'n_words': 223}