From e2eed1e79ccc45946aa87f97f7ce8b168e15d62e Mon Sep 17 00:00:00 2001 From: James Barnsley Date: Thu, 3 Feb 2022 20:34:54 +1300 Subject: [PATCH] Standard import for state; Updating GridItem which needs support for useDrag hook (render only, not actual dnd UX tests) --- __tests__/components/GridItem.test.js | 21 +- .../__snapshots__/GridItem.test.js.snap | 388 +++++++++--------- __tests__/state.js | 2 +- __tests__/views/Album.test.js | 3 +- 4 files changed, 221 insertions(+), 193 deletions(-) diff --git a/__tests__/components/GridItem.test.js b/__tests__/components/GridItem.test.js index 0cf824e8..30fa3ae3 100755 --- a/__tests__/components/GridItem.test.js +++ b/__tests__/components/GridItem.test.js @@ -1,12 +1,15 @@ import React from 'react'; import { BrowserRouter } from 'react-router-dom'; import TestRenderer from 'react-test-renderer'; +import { DndProvider } from 'react-dnd'; +import { HTML5Backend } from 'react-dnd-html5-backend'; import { GridItem } from '../../src/js/components/GridItem'; -import { core } from '../state'; +import state from '../state'; jest.mock('react-redux', () => ({ useSelector: jest.fn(), useDispatch: () => jest.fn(), + useDrag: jest.fn(), })); jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom'), @@ -21,10 +24,14 @@ jest.mock('react-router-dom', () => ({ })); describe('', () => { + const { core: { items } } = state; + it('should handle album', () => { const result = TestRenderer.create( - + + + ).toJSON(); expect(result).toMatchSnapshot(); @@ -32,7 +39,9 @@ describe('', () => { it('should handle artist', () => { const result = TestRenderer.create( - + + + ).toJSON(); expect(result).toMatchSnapshot(); @@ -40,9 +49,11 @@ describe('', () => { it('should handle playlist', () => { const result = TestRenderer.create( - + + + ).toJSON(); expect(result).toMatchSnapshot(); }); -}); \ No newline at end of file +}); diff --git a/__tests__/components/__snapshots__/GridItem.test.js.snap b/__tests__/components/__snapshots__/GridItem.test.js.snap index 32abf510..50ed0ad5 100644 --- a/__tests__/components/__snapshots__/GridItem.test.js.snap +++ b/__tests__/components/__snapshots__/GridItem.test.js.snap @@ -1,76 +1,77 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[` should handle album 1`] = ` - -
- - album - `; exports[` should handle artist 1`] = ` - -
- - perm_identity -
-
-
-
- Above & Beyond -
-
-
    - -
  • - 2 albums -
  • -
-
-
+ perm_identity + +
+
+
+
+ Above & Beyond +
+
+
    + +
  • + 2 albums +
  • +
+
+ +
`; exports[` should handle playlist 1`] = ` - -
- - queue_music -
-
-
-
- Local tester -
-
-
    - -
  • - 13 tracks -
  • -
-
-
+ queue_music + +
+
+
+
+ Local tester +
+
+
    + +
  • + 13 tracks +
  • +
+
+ +
`; diff --git a/__tests__/state.js b/__tests__/state.js index f22366ad..3427392e 100755 --- a/__tests__/state.js +++ b/__tests__/state.js @@ -259,4 +259,4 @@ state.core.items['jest:track:three'] = { ] }; -module.exports = state; +export default state; diff --git a/__tests__/views/Album.test.js b/__tests__/views/Album.test.js index b7af2475..43061473 100755 --- a/__tests__/views/Album.test.js +++ b/__tests__/views/Album.test.js @@ -4,8 +4,7 @@ import TestRenderer from 'react-test-renderer'; import { Album } from '../../src/js/views/Album'; import * as uiActions from '../../src/js/services/ui/actions'; import * as coreActions from '../../src/js/services/core/actions'; - -const state = require('../state'); +import state from '../state'; jest.mock('react-redux', () => ({ useSelector: jest.fn(),