Add more test coverage to App.test.tsx
Here are sections that are uncovered in App.tsx:
```ts
const handleGlobalKeyPress = (e: KeyboardEvent) => {
Iif (e.key === "Enter" && e.altKey) {
e.preventDefault();
handleExecuteCommand();
}
};
```
```ts
const handleCopyOutput = () => {
const output = store.outputs && store.outputs[store.outputs.length - 1];
Iif (output) {
navigator.clipboard.writeText(lastOutputString).then(() => {
store.setIsCopied(true);
setTimeout(() => store.setIsCopied(false), 2000);
});
}
};
```
```ts
const handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {
Iif (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
handleSendMessage();
}
};
```
```tsx
<button
onClick={handleCopyOutput}
className="flex items-center px-3 py-1 bg-blue-500 text-white rounded hover:bg-blue-600 transition-colors"
disabled={!store.outputs || store.outputs.length === 0}
>
{store.isCopied ? (
<>
<Check size={16} className="mr-1" />
Copied!
</>
) : (
<>
<Copy size={16} className="mr-1" />
Copy
</>
)}
</button>
</div>
```
Generally it is user input.
One thing that needs to be set up in the tests is the store.outputs because the last output is required to have the copy button work.
关闭于 2024-07-31 0 条评论