tests for EOL - LF and CRLF

This commit is contained in:
Paolo Ceschi Berrini 2020-01-14 13:02:54 +01:00
parent 60651a4727
commit e76b68729e

View File

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