{"size": 1828, "ext": "js", "max_stars_repo_path": "packages/enzyme-matchers/src/assertions/__tests__/toHaveDisplayName.test.js", "max_stars_repo_name": "ysgk/enzyme-matchers", "max_stars_repo_stars_event_min_datetime": "2018-01-30T14:54:13.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-22T13:55:16.000Z", "max_issues_repo_path": "packages/enzyme-matchers/src/assertions/__tests__/toHaveDisplayName.test.js", "max_issues_repo_name": "ysgk/enzyme-matchers", "max_issues_repo_issues_event_min_datetime": "2018-02-01T20:52:33.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-27T05:00:07.000Z", "max_forks_repo_path": "packages/enzyme-matchers/src/assertions/__tests__/toHaveDisplayName.test.js", "max_forks_repo_name": "ysgk/enzyme-matchers", "max_forks_repo_forks_event_min_datetime": "2018-02-07T17:49:40.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-24T18:27:33.000Z"}
{"max_stars_count": 568, "max_issues_count": 127, "max_forks_count": 84, "avg_line_length": 30.4666666667, "max_line_length": 94, "alphanum_fraction": 0.5919037199}
const toHaveDisplayName = require('../toHaveDisplayName');

function Fixture() {
  return (
    <div>
      <span id="span" />
      <span />
      <a id="a" />
    </div>
  );
}

describe('toHaveDisplayName', () => {
  [shallow, mount].forEach(builder => {
    describe(builder.name, () => {
      const wrapper = builder(<Fixture />).find('a');
      const truthyResults = toHaveDisplayName(wrapper, 'a');
      const falsyResults = toHaveDisplayName(wrapper, 'span');

      it('returns the pass flag properly', () => {
        expect(truthyResults.pass).toBe(true);
        expect(falsyResults.pass).toBe(false);
      });

      it(`returns the message with the proper pass verbage (${builder.name})`, () => {
        expect(truthyResults.message).toMatchSnapshot();
      });

      it(`returns the message with the proper fail verbage (${builder.name})`, () => {
        expect(truthyResults.negatedMessage).toMatchSnapshot();
      });

      it(`provides contextual information for the message (${builder.name})`, () => {
        expect(truthyResults.contextualInformation).toMatchSnapshot();
      });

      it('provides the right info for when this method is called with multiple nodes', () => {
        const nwrapper = builder(
          <div>
            <span />
            <span />
          </div>
        ).find('span');
        const nfalsyResults = toHaveDisplayName(nwrapper, 'span');

        expect(nfalsyResults).toMatchSnapshot();
      });

      it('works on composite functions', () => {
        const nwrapper = builder(<Fixture />);
        const ntruthyResults = toHaveDisplayName(nwrapper, 'Fixture');
        const nfalsyResults = toHaveDisplayName(nwrapper, 'a');

        expect(ntruthyResults).toMatchSnapshot();
        expect(nfalsyResults).toMatchSnapshot();
      });
    });
  });
});
