Skip to content

Commit

Permalink
fix: fix alias bug and jest bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamerryao committed Aug 28, 2022
1 parent 3951552 commit 737efd8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react';

import App from './App';

test('renders learn react link', () => {
test('renders made by link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
const linkElement = screen.getByText(/Dreamerryao/i);
expect(linkElement).toBeInTheDocument();
});
9 changes: 9 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import '@/App.css';

import Button from '@/components/Button';

import logo from '@/logo.svg';

const HOMEPAGE_URL = 'https://github.com/toy-playground/craco-ts-template';
function App() {
const linkToHome = () => {
window.open(HOMEPAGE_URL);
};
return (
<div className='App'>
<header className='App-header'>
Expand All @@ -22,6 +28,9 @@ function App() {
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<Button onClick={linkToHome}>
And this is a button link to github.
</Button>
</header>
</div>
);
Expand Down
12 changes: 12 additions & 0 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ReactNode } from 'react';

interface ButtonProps {
children: ReactNode;
onClick?: () => void;
}

const Button = ({ children, onClick }: ButtonProps) => {
return <button onClick={onClick}>{children}</button>;
};

export default Button;
8 changes: 5 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
"jsx": "react-jsx",
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src"],
"extends": "./tsconfig.paths.json"
"include": ["src"]
}
8 changes: 0 additions & 8 deletions tsconfig.paths.json

This file was deleted.

0 comments on commit 737efd8

Please sign in to comment.