-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Modal): fix errors with SSR #2260
Conversation
Resolve Issue Semantic-Org#2259
Codecov Report
@@ Coverage Diff @@
## master #2260 +/- ##
==========================================
+ Coverage 99.73% 99.73% +<.01%
==========================================
Files 151 151
Lines 2624 2625 +1
==========================================
+ Hits 2617 2618 +1
Misses 7 7
Continue to review full report at Codecov.
|
@layershifter PR submitted for #2259 |
src/modules/Modal/Modal.js
Outdated
@@ -155,13 +158,16 @@ class Modal extends Component { | |||
static Description = ModalDescription | |||
static Actions = ModalActions | |||
|
|||
// expose for testing | |||
static isBrowser = isBrowser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to not import isBrowser
in tests instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. I'd like to have a way to spoof isBrowser
that is not dependant on the Modal. One idea is to convert isBrowser to a function. This way, we can set a flag to override it:
const isBrowser = () => !_.isNil(isBrowser, 'override')
? isBrowser.override
: hasDocument && hasWindow
export default isBrowser
Then we can do something similar to what is being done now, except with isBrowser rather than Modal:
before(() => {
isBrowser.override = false
// isBrowser() === false
})
after(() => {
isBrowser.override = null
// isBrowser() === <appropriate value>
})
Allow isBrowser to be overridden for SSR tests
Thanks! |
Released in |
Resolve Issue #2259