Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kononnable committed Aug 22, 2020
1 parent 8bbe1a6 commit 0fad9be
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,8 @@
# Changelog

## Unreleased
* Option to generate properties with snake_case(#295)

## 0.4.2

* Use statement not available on Azure SQL (#243)
Expand Down
37 changes: 37 additions & 0 deletions test/modelCustomization/modelCustomization.test.ts
Expand Up @@ -30,6 +30,12 @@ describe("Model customization phase", async () => {
options: { name: "name" },
tscName: "name",
tscType: "string"
},
{
type: "character varying",
options: { name: "complicatedName" },
tscName: "complexName",
tscType: "string"
}
],
indices: [
Expand Down Expand Up @@ -251,6 +257,7 @@ describe("Model customization phase", async () => {
.toString();
expect(postContent).to.contain("Title: string;");
expect(postAuthorContent).to.contain("Posts: Post[];");
expect(postAuthorContent).to.contain("ComplexName: string;");

compileGeneratedModel(generationOptions.resultsPath, [""], false);
});
Expand Down Expand Up @@ -279,9 +286,39 @@ describe("Model customization phase", async () => {
.toString();
expect(postContent).to.contain("title: string;");
expect(postAuthorContent).to.contain("posts: Post[];");
expect(postAuthorContent).to.contain("complexName: string;");

compileGeneratedModel(generationOptions.resultsPath, [""]);
});
it("snake_case", () => {
const data = generateSampleData();
const generationOptions = generateGenerationOptions();
clearGenerationDir();

generationOptions.convertCaseProperty = "snake";
const customizedModel = modelCustomizationPhase(
data,
generationOptions,
{}
);
modelGenerationPhase(
getDefaultConnectionOptions(),
generationOptions,
customizedModel
);
const filesGenPath = path.resolve(resultsPath, "entities");
const postContent = fs
.readFileSync(path.resolve(filesGenPath, "Post.ts"))
.toString();
const postAuthorContent = fs
.readFileSync(path.resolve(filesGenPath, "PostAuthor.ts"))
.toString();
expect(postContent).to.contain("title: string;");
expect(postAuthorContent).to.contain("posts: Post[];");
expect(postAuthorContent).to.contain("complex_name: string;");

compileGeneratedModel(generationOptions.resultsPath, [""],false);
});
});
describe("EOL", async () => {
it("LF", () => {
Expand Down

0 comments on commit 0fad9be

Please sign in to comment.