Skip to content

Commit

Permalink
Refactor test case to include a timeout and simulate user input
Browse files Browse the repository at this point in the history
- Added a timeout of 5000ms to the test case
- Simulated user input by sending openai to stdin
- Added a short delay before sending the next input
- Simulated another input by sending y to stdin
- Ended stdin after all inputs have been sent
- Created an instance of Loz and called the init() method
- Assigned the result of the init() method to the variable res

Generated by gpt-3.5-turbo
  • Loading branch information
joone committed Feb 13, 2024
1 parent e6b154c commit 5aae5cd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/a.loz.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@ describe("Test OpenAI API", () => {
stdin.restore();
});

it("should return true", async () => {
it("should return true", async function () {
this.timeout(5000);

process.nextTick(() => {
stdin.send("openai\n");
stdin.end();
});

// Simulate a short delay before sending the next input
setTimeout(() => {
// Second input, simulate another Enter or actual input
stdin.send("y\n");
stdin.end(); // Now end the stdin after all inputs have been sent
}, 1000);

let loz = new Loz();
const res = await loz.init();

Expand Down

0 comments on commit 5aae5cd

Please sign in to comment.