-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
98 additions
and
28 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
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
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
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
44 changes: 44 additions & 0 deletions
44
...i/configuration-loader/src/generators-yml/__test__/loadRawGeneratorsConfiguration.test.ts
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,44 @@ | ||
import { AbsoluteFilePath } from "@fern-api/fs-utils"; | ||
import { createMockTaskContext } from "@fern-api/task-context"; | ||
import { promises as fs } from "fs"; | ||
import yaml from "js-yaml"; | ||
import path from "path"; | ||
import tmp from "tmp-promise"; | ||
import { beforeEach, describe, expect, it } from "vitest"; | ||
import { loadRawGeneratorsConfiguration } from "../loadGeneratorsConfiguration"; | ||
|
||
describe("loadRawGeneratorsConfiguration", () => { | ||
const mockContext = createMockTaskContext(); | ||
const validConfig = { groups: {} }; | ||
const configYaml = yaml.dump(validConfig); | ||
let tmpDir: string; | ||
|
||
beforeEach(async () => { | ||
const { path: generatedPath } = await tmp.dir({ prefix: "generators-test-", postfix: "" }); | ||
tmpDir = generatedPath; | ||
}); | ||
|
||
it("loads .yml extension", async () => { | ||
const ymlPath = path.join(tmpDir, "generators.yml"); | ||
await fs.writeFile(ymlPath, configYaml); | ||
|
||
const result = await loadRawGeneratorsConfiguration({ | ||
absolutePathToWorkspace: AbsoluteFilePath.of(tmpDir), | ||
context: mockContext | ||
}); | ||
|
||
expect(result).toEqual(validConfig); | ||
}); | ||
|
||
it("loads .yaml extension", async () => { | ||
const yamlPath = path.join(tmpDir, "generators.yaml"); | ||
await fs.writeFile(yamlPath, configYaml); | ||
|
||
const result = await loadRawGeneratorsConfiguration({ | ||
absolutePathToWorkspace: AbsoluteFilePath.of(tmpDir), | ||
context: mockContext | ||
}); | ||
|
||
expect(result).toEqual(validConfig); | ||
}); | ||
}); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.