mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
refactor: move TypeScript and TSX test code to fixture files
This commit is contained in:
parent
4580fac6fa
commit
7465b4bf91
3 changed files with 28 additions and 63 deletions
|
@ -415,42 +415,12 @@ public class Test implements Greeting {
|
||||||
),
|
),
|
||||||
"typescript": (
|
"typescript": (
|
||||||
"test.ts",
|
"test.ts",
|
||||||
"function greet(name: string): void {\n console.log(`Hello, ${name}!`);\n}\n",
|
"", # Now reads from fixture file
|
||||||
"greet", # Key symbol to check
|
"greet", # Key symbol to check
|
||||||
),
|
),
|
||||||
"tsx": (
|
"tsx": (
|
||||||
"test.tsx",
|
"test.tsx",
|
||||||
"""import React, { useState, useEffect } from 'react';
|
"", # Now reads from fixture file
|
||||||
|
|
||||||
interface UserProps {
|
|
||||||
name: string;
|
|
||||||
age?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Component with props interface
|
|
||||||
const UserGreeting: React.FC<UserProps> = ({ name, age }) => {
|
|
||||||
const [greeting, setGreeting] = useState<string>('');
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setGreeting(`Hello, ${name}${age ? ` (${age})` : ''}!`);
|
|
||||||
}, [name, age]);
|
|
||||||
|
|
||||||
return <h1>{greeting}</h1>;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Custom hook
|
|
||||||
function useCounter(initial: number = 0) {
|
|
||||||
const [count, setCount] = useState(initial);
|
|
||||||
const increment = () => setCount(c => c + 1);
|
|
||||||
return { count, increment };
|
|
||||||
}
|
|
||||||
|
|
||||||
// Constants
|
|
||||||
const DEFAULT_NAME = 'World';
|
|
||||||
const MAX_AGE = 150;
|
|
||||||
|
|
||||||
export { UserGreeting, useCounter, DEFAULT_NAME, MAX_AGE };
|
|
||||||
""",
|
|
||||||
"UserProps", # Key symbol to check
|
"UserProps", # Key symbol to check
|
||||||
),
|
),
|
||||||
"csharp": (
|
"csharp": (
|
||||||
|
|
29
tests/fixtures/languages/tsx/test.tsx
vendored
29
tests/fixtures/languages/tsx/test.tsx
vendored
|
@ -1,11 +1,30 @@
|
||||||
import React from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
|
|
||||||
interface GreetingProps {
|
interface UserProps {
|
||||||
name: string;
|
name: string;
|
||||||
|
age?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Greeting: React.FC<GreetingProps> = ({ name }) => {
|
// Component with props interface
|
||||||
return <h1>Hello, {name}!</h1>;
|
const UserGreeting: React.FC<UserProps> = ({ name, age }) => {
|
||||||
|
const [greeting, setGreeting] = useState<string>('');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setGreeting(`Hello, ${name}${age ? ` (${age})` : ''}!`);
|
||||||
|
}, [name, age]);
|
||||||
|
|
||||||
|
return <h1>{greeting}</h1>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Greeting;
|
// Custom hook
|
||||||
|
function useCounter(initial: number = 0) {
|
||||||
|
const [count, setCount] = useState(initial);
|
||||||
|
const increment = () => setCount(c => c + 1);
|
||||||
|
return { count, increment };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
const DEFAULT_NAME = 'World';
|
||||||
|
const MAX_AGE = 150;
|
||||||
|
|
||||||
|
export { UserGreeting, useCounter, DEFAULT_NAME, MAX_AGE };
|
||||||
|
|
28
tests/fixtures/languages/typescript/test.ts
vendored
28
tests/fixtures/languages/typescript/test.ts
vendored
|
@ -1,27 +1,3 @@
|
||||||
interface IMyInterface {
|
function greet(name: string): void {
|
||||||
someMethod(): void;
|
console.log(`Hello, ${name}!`);
|
||||||
}
|
|
||||||
|
|
||||||
type ExampleType = {
|
|
||||||
key: string;
|
|
||||||
value: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Status {
|
|
||||||
New,
|
|
||||||
InProgress,
|
|
||||||
Completed,
|
|
||||||
}
|
|
||||||
|
|
||||||
export class MyClass {
|
|
||||||
constructor(public value: number) {}
|
|
||||||
|
|
||||||
add(input: number): number {
|
|
||||||
return this.value + input;
|
|
||||||
return this.value + input;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function myFunction(input: number): number {
|
|
||||||
return input * 2;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue