Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change react integration test to TS #10605

Merged
merged 6 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions test/integration/node/package-lock.json

This file was deleted.

4 changes: 4 additions & 0 deletions test/integration/react-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
"description": "chart.js should work in react-browser (Web)",
"dependencies": {
"chart.js": "file:../package.tgz",
"@types/node": "^18.7.6",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"typescript": "^4.7.4",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect } from 'react';
import React, {useEffect} from 'react';
import {Chart, DoughnutController, ArcElement} from 'chart.js';
import {merge} from 'chart.js/helpers';

Expand All @@ -7,7 +7,9 @@ Chart.register(DoughnutController, ArcElement);
function App() {
useEffect(() => {
const c = Chart.getChart('myChart');
if(c) c.destroy();
if (c) {
c.destroy();
}

new Chart('myChart', {
type: 'doughnut',
Expand All @@ -17,8 +19,8 @@ function App() {
data: [2, 3]
}]
}
})
}, [])
});
}, []);

return (
<div className="App">
Expand Down
30 changes: 30 additions & 0 deletions test/integration/react-browser/src/AppAuto.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, {useEffect} from 'react';
import Chart from 'chart.js/auto';
import {merge} from 'chart.js/helpers';

function AppAuto() {
useEffect(() => {
const c = Chart.getChart('myChart');
if (c) {
c.destroy();
}

new Chart('myChart', {
type: 'doughnut',
data: {
labels: ['Chart', 'JS'],
datasets: [{
data: [2, 3]
}]
}
});
}, []);

return (
<div className="App">
<canvas id="myChart"></canvas>
</div>
);
}

export default AppAuto;
10 changes: 0 additions & 10 deletions test/integration/react-browser/src/index.js

This file was deleted.

12 changes: 12 additions & 0 deletions test/integration/react-browser/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import {render} from 'react-dom';
import App from './App';
import AppAuto from './AppAuto';

render(
<React.StrictMode>
<App />
<AppAuto />
</React.StrictMode>,
document.getElementById('root')
);
14 changes: 14 additions & 0 deletions test/integration/react-browser/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"jsx": "react",
"target": "ES6",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true,
"alwaysStrict": true,
"strict": true,
"noEmit": true
},
"include": [
"./**/*.tsx",
]
}