-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Typescript] test for save()
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// FileWriter.test.ts | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import { tmpdir } from "os"; | ||
import { AIConfigRuntime } from "../lib/config"; | ||
|
||
describe("AIConfigRuntime save()", () => { | ||
it("saves the config and checks if the config json doesn't have key filePath", () => { | ||
const tmpDir = tmpdir(); // Get the system's temporary directory | ||
const newFileName = "modified_config.json"; | ||
const tempFilePath = path.join(tmpDir, newFileName); | ||
|
||
const filePath = path.join( | ||
__dirname, | ||
"samples", | ||
"basic_chatgpt_query_config.json" | ||
); | ||
|
||
const aiconfig = AIConfigRuntime.load(filePath); | ||
// Modify and save the configuration | ||
aiconfig.save(tempFilePath); | ||
|
||
// Open and parse the saved JSON file | ||
const savedConfig = JSON.parse(fs.readFileSync(tempFilePath, "utf8")); | ||
|
||
// Perform your assertions | ||
expect(savedConfig.hasOwnProperty("filePath")).toBe(false); | ||
}); | ||
}); |