diff options
author | Mohamed Abdelnour <mohamed.k.abdelnour@gmail.com> | 2021-05-30 10:21:35 +0200 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2021-06-01 22:36:56 +0200 |
commit | 76034880ae28dafce0d0192f55e1ef6815cf0c25 (patch) | |
tree | 1896dc0468847cdb1fbc316519a400e5858a70d9 | |
parent | 768189859ab7737dc5a071a4126f90ad944f99dd (diff) |
Add TypeScriptReact syntax test file
-rw-r--r-- | tests/syntax-tests/highlighted/TypeScriptReact/app.tsx | 35 | ||||
-rw-r--r-- | tests/syntax-tests/source/TypeScriptReact/LICENSE.md | 25 | ||||
-rw-r--r-- | tests/syntax-tests/source/TypeScriptReact/app.tsx | 35 |
3 files changed, 95 insertions, 0 deletions
diff --git a/tests/syntax-tests/highlighted/TypeScriptReact/app.tsx b/tests/syntax-tests/highlighted/TypeScriptReact/app.tsx new file mode 100644 index 00000000..4fafc1ee --- /dev/null +++ b/tests/syntax-tests/highlighted/TypeScriptReact/app.tsx @@ -0,0 +1,35 @@ +[38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;190;132;255m*[0m[38;2;248;248;242m [0m[38;2;249;38;114mas[0m[38;2;248;248;242m [0m[38;2;255;255;255mReact[0m[38;2;248;248;242m [0m[38;2;249;38;114mfrom[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116mreact[0m[38;2;230;219;116m"[0m[38;2;248;248;242m;[0m +[38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m [0m[38;2;255;255;255mHelloComponent[0m[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114mfrom[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m./hello[0m[38;2;230;219;116m"[0m[38;2;248;248;242m;[0m +[38;2;249;38;114mimport[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m [0m[38;2;255;255;255mNameEditComponent[0m[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114mfrom[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m./nameEdit[0m[38;2;230;219;116m"[0m[38;2;248;248;242m;[0m + +[38;2;249;38;114mexport[0m[38;2;248;248;242m [0m[3;38;2;102;217;239mconst[0m[38;2;248;248;242m [0m[38;2;166;226;46mApp[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m +[38;2;248;248;242m [0m[3;38;2;102;217;239mconst[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[38;2;255;255;255mname[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;255;255;255msetName[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mReact[0m[38;2;248;248;242m.[0m[38;2;166;226;46museState[0m[38;2;255;255;255m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mdefaultUserName[0m[38;2;230;219;116m"[0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m +[38;2;248;248;242m [0m[3;38;2;102;217;239mconst[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[38;2;255;255;255meditingName[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;255;255;255msetEditingName[0m[38;2;248;248;242m][0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;255;255;255mReact[0m[38;2;248;248;242m.[0m[38;2;166;226;46museState[0m[38;2;255;255;255m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mdefaultUserName[0m[38;2;230;219;116m"[0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m + +[38;2;248;248;242m [0m[3;38;2;102;217;239mconst[0m[38;2;248;248;242m [0m[38;2;166;226;46mloadUsername[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m +[38;2;248;248;242m [0m[38;2;102;217;239msetTimeout[0m[38;2;255;255;255m([0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m +[38;2;248;248;242m [0m[38;2;166;226;46msetName[0m[38;2;255;255;255m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mname from async call[0m[38;2;230;219;116m"[0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m +[38;2;248;248;242m [0m[38;2;166;226;46msetEditingName[0m[38;2;255;255;255m([0m[38;2;230;219;116m"[0m[38;2;230;219;116mname from async call[0m[38;2;230;219;116m"[0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m +[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;190;132;255m500[0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m +[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m;[0m + +[38;2;248;248;242m [0m[38;2;255;255;255mReact[0m[38;2;248;248;242m.[0m[38;2;166;226;46museEffect[0m[38;2;255;255;255m([0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m +[38;2;248;248;242m [0m[38;2;166;226;46mloadUsername[0m[38;2;255;255;255m([0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m +[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m,[0m[38;2;248;248;242m [0m[38;2;248;248;242m[[0m[38;2;248;248;242m][0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m + +[38;2;248;248;242m [0m[3;38;2;102;217;239mconst[0m[38;2;248;248;242m [0m[38;2;166;226;46msetUsernameState[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[3;38;2;102;217;239m=>[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m +[38;2;248;248;242m [0m[38;2;166;226;46msetName[0m[38;2;255;255;255m([0m[38;2;255;255;255meditingName[0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m +[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m;[0m + +[38;2;248;248;242m [0m[38;2;249;38;114mreturn[0m[38;2;248;248;242m [0m[38;2;255;255;255m([0m +[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[38;2;255;255;255m>[0m +[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[3;38;2;166;226;46mHelloComponent[0m[38;2;248;248;242m [0m[38;2;166;226;46muserName[0m[38;2;249;38;114m=[0m[38;2;248;248;242m{[0m[38;2;255;255;255mname[0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;255;255;255m/>[0m +[38;2;248;248;242m [0m[38;2;255;255;255m<[0m[3;38;2;166;226;46mNameEditComponent[0m +[38;2;248;248;242m [0m[38;2;166;226;46minitialUserName[0m[38;2;249;38;114m=[0m[38;2;248;248;242m{[0m[38;2;255;255;255mname[0m[38;2;248;248;242m}[0m +[38;2;248;248;242m [0m[38;2;166;226;46meditingName[0m[38;2;249;38;114m=[0m[38;2;248;248;242m{[0m[38;2;255;255;255meditingName[0m[38;2;248;248;242m}[0m +[38;2;248;248;242m [0m[38;2;166;226;46monNameUpdated[0m[38;2;249;38;114m=[0m[38;2;248;248;242m{[0m[38;2;255;255;255msetUsernameState[0m[38;2;248;248;242m}[0m +[38;2;248;248;242m [0m[38;2;166;226;46monEditingNameUpdated[0m[38;2;249;38;114m=[0m[38;2;248;248;242m{[0m[38;2;255;255;255msetEditingName[0m[38;2;248;248;242m}[0m +[38;2;248;248;242m [0m[38;2;255;255;255m/>[0m +[38;2;248;248;242m [0m[38;2;255;255;255m</[0m[38;2;255;255;255m>[0m +[38;2;248;248;242m [0m[38;2;255;255;255m)[0m[38;2;248;248;242m;[0m +[38;2;248;248;242m}[0m[38;2;248;248;242m;[0m diff --git a/tests/syntax-tests/source/TypeScriptReact/LICENSE.md b/tests/syntax-tests/source/TypeScriptReact/LICENSE.md new file mode 100644 index 00000000..a2ac8db4 --- /dev/null +++ b/tests/syntax-tests/source/TypeScriptReact/LICENSE.md @@ -0,0 +1,25 @@ +The `app.tsx` file has been added from https://github.com/Lemoncode/react-typescript-samples under the following license: + +```text +The MIT License (MIT) + +Copyright (c) 2016 brauliodiez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` diff --git a/tests/syntax-tests/source/TypeScriptReact/app.tsx b/tests/syntax-tests/source/TypeScriptReact/app.tsx new file mode 100644 index 00000000..e02695fb --- /dev/null +++ b/tests/syntax-tests/source/TypeScriptReact/app.tsx @@ -0,0 +1,35 @@ +import * as React from "react"; +import { HelloComponent } from "./hello"; +import { NameEditComponent } from "./nameEdit"; + +export const App = () => { + const [name, setName] = React.useState("defaultUserName"); + const [editingName, setEditingName] = React.useState("defaultUserName"); + + const loadUsername = () => { + setTimeout(() => { + setName("name from async call"); + setEditingName("name from async call"); + }, 500); + }; + + React.useEffect(() => { + loadUsername(); + }, []); + + const setUsernameState = () => { + setName(editingName); + }; + + return ( + <> + <HelloComponent userName={name} /> + <NameEditComponent + initialUserName={name} + editingName={editingName} + onNameUpdated={setUsernameState} + onEditingNameUpdated={setEditingName} + /> + </> + ); +}; |