GitNexus/gitnexus/test/fixtures/sample-code/simple.tsx
abhigyanpatwari 8a100a76d3 test: add test suite with vitest (unit + integration + fixtures)
- 59 test files covering unit and integration tests
- vitest config with coverage thresholds and fork pooling
- Test fixtures (mini-repo + multi-language sample code)
- Add vitest + coverage-v8 to devDependencies
- Add test scripts (test, test:integration, test:all, test:watch, test:coverage)
- Move typescript to devDependencies where it belongs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 20:07:02 +05:30

41 lines
947 B
TypeScript

import React, { useState } from 'react';
interface ButtonProps {
label: string;
onClick: () => void;
}
export class Counter extends React.Component<{}, { count: number }> {
state = { count: 0 };
increment() {
this.setState({ count: this.state.count + 1 });
}
render() {
return <button onClick={() => this.increment()}>{this.state.count}</button>;
}
}
export const Button: React.FC<ButtonProps> = ({ label, onClick }) => {
return <button onClick={onClick}>{label}</button>;
};
export function useCounter(initial: number = 0) {
const [count, setCount] = useState(initial);
const increment = () => setCount(c => c + 1);
const decrement = () => setCount(c => c - 1);
return { count, increment, decrement };
}
const App = () => {
const { count, increment } = useCounter();
return (
<div>
<h1>Count: {count}</h1>
<Button label="+" onClick={increment} />
</div>
);
};
export default App;