-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from UXPin/20301-add-unit-test-for-ts-support
20301 add unit test for ts support
- Loading branch information
Showing
5 changed files
with
277 additions
and
0 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
20 changes: 20 additions & 0 deletions
20
packages/uxpin-merge-cli/test/resources/components/typescript/ClassWithArrayOfUnionType.tsx
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,20 @@ | ||
import * as React from 'react'; | ||
|
||
export type Error = | ||
| string | ||
| React.ReactElement<any> | ||
| (string | React.ReactElement<any>)[]; | ||
|
||
interface Props { | ||
propWithArrayOfUnion: Error; | ||
} | ||
|
||
export default class ClassWithArrayOfUnionType extends React.Component<Props> { | ||
public render(): JSX.Element { | ||
const {propWithArrayOfUnion} = this.props; | ||
return ( | ||
<div> | ||
<button>{propWithArrayOfUnion}</button> | ||
</div>) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/uxpin-merge-cli/test/resources/components/typescript/ClassWithExtendedInterface.tsx
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,33 @@ | ||
import * as React from 'react'; | ||
|
||
interface Action { | ||
actionType:string; | ||
} | ||
|
||
interface DisableableAction extends Action { | ||
disabled?:boolean; | ||
} | ||
|
||
interface IconableAction { | ||
iconType:string; | ||
size:number; | ||
} | ||
|
||
interface ExtendedInterface extends IconableAction, DisableableAction { | ||
helpText?: string; | ||
image: string; | ||
} | ||
|
||
export default class ClassWithExtendedInterface extends React.Component<ExtendedInterface> { | ||
|
||
public render():JSX.Element { | ||
const { helpText, disabled } = this.props; | ||
return ( | ||
<div> | ||
<button disabled={disabled}> | ||
{helpText} | ||
</button> | ||
</div> | ||
); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ges/uxpin-merge-cli/test/resources/components/typescript/ClassWithTwoDimensionalArray.tsx
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,20 @@ | ||
import * as React from 'react'; | ||
|
||
type TableData = string | number | React.ReactNode; | ||
|
||
interface Props { | ||
rows:TableData[][], | ||
} | ||
|
||
export default class ClassWithTwoDimensionalArray extends React.Component<Props> { | ||
public render():JSX.Element { | ||
const { rows } = this.props; | ||
return ( | ||
<div> | ||
<button> | ||
{rows} | ||
</button> | ||
</div> | ||
); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...pin-merge-cli/test/resources/components/typescript/FunctionWithCombinedPropertiesType.tsx
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,40 @@ | ||
import * as React from 'react'; | ||
import { ExternalShapeType, NestedShape } from './ExternalShapeType'; | ||
import { withI18n } from './hoc/withI18n'; | ||
|
||
export function labelID(item:NestedShape):string { | ||
return `${item.keyA}Label`; | ||
} | ||
|
||
export interface Props { | ||
/** | ||
* Local property | ||
*/ | ||
id:string; | ||
hidden:boolean; | ||
children?:string; | ||
} | ||
|
||
export type CombinedType = Props & ExternalShapeType; | ||
|
||
/** | ||
* @uxpincomponent | ||
*/ | ||
function FunctionWithCombinedPropertiesType({ | ||
children, | ||
hidden, | ||
id, | ||
nested: { keyA, keyB }, | ||
}:CombinedType) { | ||
return ( | ||
<div> | ||
<label id={labelID({ keyA, keyB })} | ||
htmlFor={id} | ||
className={hidden ? 'hidden' : ''}> | ||
{children} | ||
</label> | ||
</div> | ||
); | ||
} | ||
|
||
export default withI18n(FunctionWithCombinedPropertiesType); |