import { cleanup } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';

import getNavigation from '~tests/factories/sections/navigationStatic.factory';
import { getMenuObj, itemHasChildren } from '~helpers/menu';

let data;
let section;

beforeEach(() => {
  data = getNavigation();
  section = {
    modules: [data],
  };
});
describe('Menu Helper', () => {
  test('test getting menu obj from module', () => {
    const menu = getMenuObj(section.modules, 'menu');
    expect(menu.children).toHaveLength(6);
    expect(menu.children[3].children).toHaveLength(4);
  });
  test('test has Children', () => {
    const menu = getMenuObj(section.modules, 'menu');
    expect(itemHasChildren(menu.children[1])).toBeFalsy();
    expect(itemHasChildren(menu.children[3])).toBeTruthy();
  });
});
afterEach(() => {
  cleanup();
});
