From 7d2d9e5c2ae556a598e1d2fa3f763eca679026be Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Sun, 21 Nov 2021 19:57:02 +1300 Subject: [PATCH] Actual test for base App (shallow render only, for now) --- __tests__/App.test.js | 67 +++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 41 deletions(-) diff --git a/__tests__/App.test.js b/__tests__/App.test.js index ebca2019..391d63bb 100755 --- a/__tests__/App.test.js +++ b/__tests__/App.test.js @@ -1,45 +1,30 @@ +import React from 'react'; +import ShallowRenderer from 'react-test-renderer/shallow' +import App from '../src/js/App'; -import React from 'react';; -import ReactDOM from 'react-dom';; -import { Provider } from 'react-redux'; -import { createStore } from 'redux'; -import { BrowserRouter, Route, IndexRoute } from "react-router-dom"; - -// Testing-specific -import renderer from 'react-test-renderer'; -import { shallow, mount, render } from 'enzyme'; - -// Test subjects -import store from '../src/js/store'; -import * as coreActions from '../src/js/services/core/actions'; -import * as uiActions from '../src/js/services/ui/actions'; -import * as pusherActions from '../src/js/services/pusher/actions'; -import * as mopidyActions from '../src/js/services/mopidy/actions'; -import * as spotifyActions from '../src/js/services/spotify/actions'; -import * as lastfmActions from '../src/js/services/lastfm/actions'; -import * as geniusActions from '../src/js/services/genius/actions'; -import * as snapcastActions from '../src/js/services/snapcast/actions'; -import { App } from '../src/js/App'; +jest.mock('react-redux', () => ({ + useSelector: jest.fn(), + useDispatch: () => jest.fn(), + connect: () => jest.fn(), +})); +jest.mock('react-router-dom', () => ({ + ...jest.requireActual('react-router-dom'), + useHistory: () => ({ + location: { + pathname: 'iris.local:6680/iris', + }, + }), + useLocation: () => ({ + pathname: 'iris.local:6680/iris', + }), +})); describe('', () => { - - it('should render', () => { - const dom = shallow( - - ); - - - }); + it('should render', () => { + const renderer = new ShallowRenderer(); + renderer.render(); + const result = renderer.getRenderOutput(); + expect(result.type).toEqual('div'); + expect(Array.isArray(result.props.children)).toEqual(true); + }); }); -