-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update Modal's mock to not render its children when it is not visible
- Loading branch information
AntoineDoubovetzky
committed
Oct 6, 2021
1 parent
778845a
commit cdab5f0
Showing
3 changed files
with
39 additions
and
7 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,32 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @flow strict-local | ||
*/ | ||
|
||
/* eslint-env jest */ | ||
|
||
'use strict'; | ||
|
||
const React = require('react'); | ||
const Modal = require('../Libraries/Modal/Modal'); | ||
|
||
function mockModal(BaseComponent: $FlowFixMe) { | ||
class ModalMock extends BaseComponent { | ||
render(): React.Element<typeof Modal> { | ||
return ( | ||
<BaseComponent | ||
{...this.props} | ||
children={this.props.visible !== true ? null : this.props.children} | ||
/> | ||
); | ||
} | ||
} | ||
return ModalMock; | ||
} | ||
|
||
module.exports = (mockModal: $FlowFixMe); |
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