forked from wellcometrust/next-plugin-transpile-modules
-
-
Notifications
You must be signed in to change notification settings - Fork 85
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 #103 from martpie/test-react-components
Add integration test for a TypeScript react component
- Loading branch information
Showing
5 changed files
with
36 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
|
||
type Props = { | ||
underlined: boolean; | ||
}; | ||
|
||
export const Subtitle: React.FC<Props> = (props) => { | ||
return <h2 style={{ textDecoration: props.underlined ? 'underline' : 'none' }}>{props.children}</h2>; | ||
}; |
8 changes: 7 additions & 1 deletion
8
src/__tests__/__apps__/npm-basic/pages/test-local-typescript-module.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 |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import React from 'react'; | ||
import { add } from 'shared-ts/utils/calc'; | ||
import { Subtitle } from 'shared-ts/components/Subtitle'; | ||
|
||
const HomePage: React.FC = () => { | ||
return <h1>The answer is {add(40, 3)}</h1>; | ||
return ( | ||
<> | ||
<h1>The answer is {add(40, 3)}</h1> | ||
<Subtitle underlined>And this is a subtitle</Subtitle> | ||
</> | ||
); | ||
}; | ||
|
||
export default HomePage; |
9 changes: 9 additions & 0 deletions
9
src/__tests__/__apps__/yarn-workspaces/_shared-ts/components/Subtitle.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,9 @@ | ||
import React from 'react'; | ||
|
||
type Props = { | ||
underlined: boolean; | ||
}; | ||
|
||
export const Subtitle: React.FC<Props> = (props) => { | ||
return <h2 style={{ textDecoration: props.underlined ? 'underline' : 'none' }}>{props.children}</h2>; | ||
}; |
8 changes: 7 additions & 1 deletion
8
src/__tests__/__apps__/yarn-workspaces/app/pages/test-local-typescript-module.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 |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import React from 'react'; | ||
import { add } from 'shared-ts/utils/calc'; | ||
import { Subtitle } from 'shared-ts/components/Subtitle'; | ||
|
||
const HomePage: React.FC = () => { | ||
return <h1>The answer is {add(40, 3)}</h1>; | ||
return ( | ||
<div> | ||
<h1>The answer is {add(40, 3)}</h1> | ||
<Subtitle underlined>And this is a subtitle</Subtitle> | ||
</div> | ||
); | ||
}; | ||
|
||
export default HomePage; |
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