This commit is contained in:
kononnable 2020-08-22 09:35:21 +02:00
parent 8bbe1a617d
commit 0fad9be442
2 changed files with 40 additions and 0 deletions

View File

@ -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)

View File

@ -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: [
@ -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);
});
@ -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", () => {