/* global expect */ import React from 'react'; import ShallowRenderer from 'react-test-renderer/shallow'; import TestRenderer from 'react-test-renderer'; import { UniversalNav } from './components/UniversalNav'; import NavLinks from './components/NavLinks'; describe('', () => { it('renders to the DOM', () => { const shallow = new ShallowRenderer(); shallow.render(); const result = shallow.getRenderOutput(); expect(result).toBeTruthy(); }); }); describe('', () => { const root = TestRenderer.create().root; const aTags = root.findAllByType('a'); // reduces the aTags to href links const links = aTags.reduce((acc, item) => { acc.push(item._fiber.pendingProps.href); return acc; }, []); const expectedLinks = ['/learn', '/portfolio']; it('renders to the DOM', () => { expect(root).toBeTruthy(); }); it('has 2 links', () => { expect(aTags.length === 2).toBeTruthy(); }); it('has links to learn and portfolio', () => { // checks if all links in expected links exist in links expect(expectedLinks.every(elem => links.indexOf(elem) > -1)).toBeTruthy(); }); }); const UniversalNavProps = { displayMenu: false, menuButtonRef: {}, toggleDisplayMenu: function() {} };