Skip to content

Commit a6d06ab

Browse files
authored
Generator - rearrange (#4961)
* Generator - rearrange * Reove default prop
1 parent 5f87425 commit a6d06ab

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

.wuf/generator/templates/$ComponentName/$ComponentName.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,6 @@ import { dataHooks } from './constants';
88

99
/** <%= description %> */
1010
class <%= ComponentName %> extends React.PureComponent {
11-
static displayName = '<%= ComponentName %>';
12-
13-
static propTypes = {
14-
dataHook: PropTypes.string,
15-
16-
/** Text for the button */
17-
buttonText: PropTypes.string,
18-
};
19-
20-
static defaultProps = {
21-
buttonText: 'Click me!',
22-
};
23-
2411
state = {
2512
count: 0,
2613
};
@@ -37,7 +24,10 @@ class <%= ComponentName %> extends React.PureComponent {
3724
const isEven = count % 2 === 0;
3825

3926
return (
40-
<div {...styles('root', { even: isEven, odd: !isEven }, this.props)} data-hook={dataHook}>
27+
<div
28+
{...styles('root', { even: isEven, odd: !isEven }, this.props)}
29+
data-hook={dataHook}
30+
>
4131
<Text dataHook={dataHooks.<%= componentName %>Count}>
4232
You clicked this button {isEven ? 'even' : 'odd'} number (
4333
<span className={styles.number}>
@@ -59,4 +49,20 @@ class <%= ComponentName %> extends React.PureComponent {
5949
}
6050
}
6151

52+
<%= ComponentName %>.displayName = '<%= ComponentName %>';
53+
54+
<%= ComponentName %>.propTypes = {
55+
/** Applied as data-hook HTML attribute that can be used in the tests */
56+
dataHook: PropTypes.string,
57+
58+
/** A css class to be applied to the component's root element */
59+
className: PropTypes.string,
60+
61+
/** Text for the button */
62+
buttonText: PropTypes.string,
63+
};
64+
65+
<%= ComponentName %>.defaultProps = {
66+
};
67+
6268
export default <%= ComponentName %>;

.wuf/generator/templates/$ComponentName/$ComponentName.uni.driver.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { baseUniDriverFactory } from 'wix-ui-test-utils/base-driver';
2-
import { dataHooks } from "./constants";
2+
import { dataHooks } from './constants';
33

4-
export const <%= componentName %>DriverFactory = base => {
4+
export const <%= componentName %>DriverFactory = (base, body) => {
55
return {
6-
...baseUniDriverFactory(base),
6+
...baseUniDriverFactory(base, body),
77

88
/** Get the current count */
99
getCountText: async () =>

.wuf/generator/templates/$ComponentName/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as React from 'react';
22

3-
43
export interface <%= ComponentName %>Props {
54
dataHook?: string;
5+
className?: string;
66
buttonText?: string;
77
}
88

.wuf/generator/templates/$ComponentName/test/$ComponentName.private.uni.driver.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { <%= componentName %>DriverFactory as publicDriverFactory } from '../<%= ComponentName %>.uni.driver';
22

3-
export const <%= componentName %>PrivateDriverFactory = base => {
3+
export const <%= componentName %>PrivateDriverFactory = (base, body) => {
44
return {
5-
...publicDriverFactory(base),
5+
...publicDriverFactory(base, body),
66

77
// Add here driver methods that considered "private"
88
};

0 commit comments

Comments
 (0)