From e76b68729e7fc9c8471d28c68b5770170b050d7e Mon Sep 17 00:00:00 2001 From: Paolo Ceschi Berrini Date: Tue, 14 Jan 2020 13:02:54 +0100 Subject: [PATCH] :white_check_mark: tests for EOL - LF and CRLF --- .../modelCustomization.test.ts | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/test/modelCustomization/modelCustomization.test.ts b/test/modelCustomization/modelCustomization.test.ts index 8082c48..ad54d58 100644 --- a/test/modelCustomization/modelCustomization.test.ts +++ b/test/modelCustomization/modelCustomization.test.ts @@ -283,6 +283,53 @@ describe("Model customization phase", async () => { compileGeneratedModel(generationOptions.resultsPath, [""]); }); }); + describe("EOL", async () => { + it("LF", () => { + const data = generateSampleData(); + const generationOptions = generateGenerationOptions(); + clearGenerationDir(); + generationOptions.convertEol = "\n"; + const customizedModel = modelCustomizationPhase( + data, + generationOptions, + {} + ); + modelGenerationPhase( + getDefaultConnectionOptions(), + generationOptions, + customizedModel + ); + const filesGenPath = path.resolve(resultsPath, "entities"); + const posterContent = fs + .readFileSync(path.resolve(filesGenPath, "Post.ts")) + .toString(); + expect(posterContent).to.not.contain("\r\n"); + expect(posterContent).to.contain("\n"); + compileGeneratedModel(generationOptions.resultsPath, [""]); + }); + it("CRLF", () => { + const data = generateSampleData(); + const generationOptions = generateGenerationOptions(); + clearGenerationDir(); + generationOptions.convertEol = "\r\n"; + const customizedModel = modelCustomizationPhase( + data, + generationOptions, + {} + ); + modelGenerationPhase( + getDefaultConnectionOptions(), + generationOptions, + customizedModel + ); + const filesGenPath = path.resolve(resultsPath, "entities"); + const posterContent = fs + .readFileSync(path.resolve(filesGenPath, "Post.ts")) + .toString(); + expect(posterContent).to.contain("\r\n"); + compileGeneratedModel(generationOptions.resultsPath, [""]); + }); + }); describe("property-visibility", () => { it("public", () => { const data = generateSampleData();