{"size": 1885, "ext": "js", "max_stars_repo_path": "packages/vue-components/src/__tests__/Dropdown.spec.js", "max_stars_repo_name": "tlylt/markbind", "max_stars_repo_stars_event_min_datetime": "2017-01-20T03:26:50.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-25T07:45:30.000Z", "max_issues_repo_path": "packages/vue-components/src/__tests__/Dropdown.spec.js", "max_issues_repo_name": "tlylt/markbind", "max_issues_repo_issues_event_min_datetime": "2017-01-14T16:02:03.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T17:29:56.000Z", "max_forks_repo_path": "packages/vue-components/src/__tests__/Dropdown.spec.js", "max_forks_repo_name": "tlylt/markbind", "max_forks_repo_forks_event_min_datetime": "2017-06-24T02:50:07.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-06T06:06:05.000Z"}
{"max_stars_count": 78, "max_issues_count": 1532, "max_forks_count": 102, "avg_line_length": 26.5492957746, "max_line_length": 71, "alphanum_fraction": 0.624933687}
import { mount } from '@vue/test-utils';
import Dropdown from '../Dropdown.vue';
import Submenu from '../Submenu.vue';

const DEFAULT_STUBS = {
  'dropdown': Dropdown,
  'submenu': Submenu,
};

const DROPDOWN = `
<li><a href="#" class="dropdown-item">Dropdown Item 1</a></li>
<li><a href="#" class="dropdown-item">Dropdown Item 2</a></li>
<li><a href="#" class="dropdown-item">Dropdown Item 3</a></li>
`;

const FIRST_LEVEL_NESTED_DROPDOWN = `
${DROPDOWN}
<dropdown haeder="Submenu Level 1">
  <li><a href="#" class="dropdown-item">Nested Dropdown Item 1</a></li>
  <li><a href="#" class="dropdown-item">Nested Dropdown Item 2</a></li>
</dropdown>
`;

const SECOND_LEVEL_NESTED_DROPDOWN = `
<dropdown haeder="Submenu Level 1">
  <li><a href="#" class="dropdown-item">Nested Dropdown Item 1</a></li>
  <li><a href="#" class="dropdown-item">Nested Dropdown Item 2</a></li>
  <dropdown haeder="Submenu Level 2">
    <li><a href="#" class="dropdown-item">Nested Submenu Item</a></li>
  </dropdown>
</dropdown>
`;

describe('Dropdown with submenu', () => {
  test('dropdown', async () => {
    const wrapper = mount(Dropdown, {
      slots: {
        header: 'Test Dropdown',
        default: DROPDOWN,
      },
      stubs: DEFAULT_STUBS,
    });

    expect(wrapper.element).toMatchSnapshot();
  });

  test('dropdown with one level of submenu', async () => {
    const wrapper = mount(Dropdown, {
      slots: {
        header: 'Test Dropdown',
        default: FIRST_LEVEL_NESTED_DROPDOWN,
      },
      stubs: DEFAULT_STUBS,
    });

    expect(wrapper.element).toMatchSnapshot();
  });

  test('dropdown with two levels of submenu', async () => {
    const wrapper = mount(Dropdown, {
      slots: {
        header: 'Test Dropdown',
        default: SECOND_LEVEL_NESTED_DROPDOWN,
      },
      stubs: DEFAULT_STUBS,
    });

    expect(wrapper.element).toMatchSnapshot();
  });
});
