import React from 'react'; import { Route, MemoryRouter } from 'react-router-dom'; import { createStore } from 'redux'; import { Provider } from 'react-redux'; import { mount } from 'enzyme'; import assert from 'assert'; import RoutesWithLayout from './RoutesWithLayout'; describe('', () => { const Dashboard = () =>
Dashboard
; const Custom = ({ name }) =>
Custom
; const FirstResource = ({ name }) =>
Default
; const Resource = ({ name }) =>
Resource
; // the Provider is required because the dashboard is wrapped by , which is a connected component const store = createStore(() => ({ admin: { auth: { isLoggedIn: true } }, })); it('should show dashboard on / when provided', () => { const wrapper = mount( ); assert.equal(wrapper.find(Dashboard).length, 1); }); it('should show the first resource on / when there is only one resource and no dashboard', () => { const wrapper = mount( ); assert.equal(wrapper.find(FirstResource).length, 1); }); it('should show the first resource on / when there are multiple resource and no dashboard', () => { const wrapper = mount( ); assert.equal(wrapper.find(FirstResource).length, 1); assert.equal(wrapper.find(Resource).length, 0); }); it('should accept custom routes', () => { const customRoutes = [ , ]; // eslint-disable-line react/jsx-key const wrapper = mount( ); assert.equal(wrapper.find(Custom).length, 1); }); });