Skip to content

Commit 1d40f1d

Browse files
committed
Add test
1 parent 2f3762f commit 1d40f1d

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from "react";
2+
import PropTypes from "prop-types";
3+
4+
const AddPropsComponent = (props) => {
5+
const {children, id} = props;
6+
7+
8+
return (
9+
<div id={id}>
10+
{React.cloneElement(children, {
11+
receive: `Element #${id} pass`,
12+
id: id,
13+
})}
14+
</div>
15+
);
16+
};
17+
18+
AddPropsComponent.propTypes = {
19+
id: PropTypes.string,
20+
children: PropTypes.node,
21+
};
22+
23+
export default AddPropsComponent;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
const ReceivePropsComponent = (props) => {
5+
const {id, text, receive} = props;
6+
7+
return (
8+
<div id={id}>
9+
{receive || text}
10+
</div>
11+
);
12+
}
13+
ReceivePropsComponent.propTypes = {
14+
id: PropTypes.string,
15+
text: PropTypes.string,
16+
receive: PropTypes.string,
17+
}
18+
19+
export default ReceivePropsComponent;

@plotly/dash-test-components/src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import MyPersistedComponentNested from './components/MyPersistedComponentNested'
77
import StyledComponent from './components/StyledComponent';
88
import WidthComponent from './components/WidthComponent';
99
import ComponentAsProp from './components/ComponentAsProp';
10+
import AddPropsComponent from "./components/AddPropsComponent";
11+
import ReceivePropsComponent from "./components/ReceivePropsComponent";
1012

1113
export {
1214
AsyncComponent,
@@ -18,4 +20,6 @@ export {
1820
StyledComponent,
1921
WidthComponent,
2022
ComponentAsProp,
23+
AddPropsComponent,
24+
ReceivePropsComponent
2125
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from dash import Dash, html
2+
3+
from dash_test_components import AddPropsComponent, ReceivePropsComponent
4+
5+
6+
def test_dvui001_add_receive_props(dash_duo):
7+
app = Dash(__name__)
8+
app.layout = html.Div(
9+
[
10+
AddPropsComponent(
11+
ReceivePropsComponent(
12+
id='test-receive1',
13+
text='receive component1',
14+
),
15+
id='test-add'
16+
),
17+
ReceivePropsComponent(
18+
id='test-receive2',
19+
text='receive component2',
20+
),
21+
]
22+
)
23+
24+
dash_duo.start_server(
25+
app,
26+
debug=True,
27+
use_reloader=False,
28+
use_debugger=True,
29+
dev_tools_hot_reload=False,
30+
dev_tools_props_check=False,
31+
)

0 commit comments

Comments
 (0)