-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overlay is now a HOC, so the ref needs to be restored. See discussion at reduxjs/react-redux#914, which is a related issue; this is the scenario where forwardRef is described as not possible from user code. To work around, this manually stores & gets the Overlay instance. Note: I wasn't able to assert the needed state with enzyme; hence the test renderer.
- Loading branch information
Showing
3 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* eslint-env jest */ | ||
import React from 'react'; | ||
import { createStore } from 'redux'; | ||
import TestRenderer from 'react-test-renderer'; | ||
|
||
import ConnectedOverlay, { Overlay } from '../Overlay'; | ||
|
||
describe('Connect(Overlay)', () => { | ||
let mockStore; | ||
|
||
beforeEach(() => { | ||
mockStore = createStore(() => ({ | ||
deviceSettings: {}, | ||
})); | ||
}); | ||
|
||
it('stores a ref to support getWrappedInstance()', () => { | ||
const ref = React.createRef(); | ||
TestRenderer.create(<ConnectedOverlay ref={ref} store={mockStore} />); | ||
expect(ref.current.getWrappedInstance).toBeInstanceOf(Function); | ||
expect(ref.current.getWrappedInstance()).toBeInstanceOf(Overlay); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters