feat: universal navbar (#36744)

* feat: add universal nav

* fix: add portfolio redirect
This commit is contained in:
Ahmad Abdolsaheb
2019-09-19 19:45:01 +03:00
committed by mrugesh
parent 5d946f3d77
commit e653235d94
24 changed files with 562 additions and 370 deletions

View File

@ -0,0 +1,41 @@
/* global expect */
import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow';
import TestRenderer from 'react-test-renderer';
import Header from './';
import NavLinks from './components/NavLinks';
describe('<Header />', () => {
it('renders to the DOM', () => {
const shallow = new ShallowRenderer();
shallow.render(<Header />);
const result = shallow.getRenderOutput();
expect(result).toBeTruthy();
});
});
describe('<NavLinks />', () => {
const root = TestRenderer.create(<NavLinks />).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 = ['/', '/portfolio'];
it('renders to the DOM', () => {
expect(root).toBeTruthy();
});
it('has 2 a tags', () => {
expect(aTags.length === 2).toBeTruthy();
});
it('has link to portfolio', () => {
// checks if all links in expected links exist in links
expect(expectedLinks.every(elem => links.indexOf(elem) > -1)).toBeTruthy();
});
});