From f797b6310ea73c8ab5637ed415faab221115ea30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leyla=20J=C3=A4hnig?= <77127505+xDivisionByZerox@users.noreply.github.com> Date: Sat, 23 Apr 2022 12:55:21 +0200 Subject: feat: configure eol character for git.commitEntry (#681) --- test/git.spec.ts | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/git.spec.ts b/test/git.spec.ts index 5da5deb5..18451abd 100644 --- a/test/git.spec.ts +++ b/test/git.spec.ts @@ -116,7 +116,7 @@ describe('git', () => { }); describe('commitEntry', () => { - it('should return a random commitEntry', () => { + it('should return a valid random commitEntry', () => { const commitEntry = faker.git.commitEntry(); expect(commitEntry).toBeTruthy(); @@ -141,6 +141,36 @@ describe('git', () => { expect(parts[4]).toMatch(/^\s{4}.+$/); } }); + + it('should return a random commitEntry with a default end of line charcter of "\r\n"', () => { + const commitEntry = faker.git.commitEntry(); + const parts = commitEntry.split('\r\n'); + + expect(parts.length).toBeGreaterThanOrEqual(6); + expect(parts.length).toBeLessThanOrEqual(7); + }); + + it('should return a random commitEntry with a configured end of line charcter of "\r\n" with eol = CRLF', () => { + const commitEntry = faker.git.commitEntry({ + eol: 'CRLF', + }); + const parts = commitEntry.split('\r\n'); + + expect(parts.length).toBeGreaterThanOrEqual(6); + expect(parts.length).toBeLessThanOrEqual(7); + }); + + it('should return a random commitEntry with a configured end of line charcter of "\n" with eol = LF', () => { + const commitEntry = faker.git.commitEntry({ + eol: 'LF', + }); + const parts = commitEntry.split('\n'); + + expect(parts.length).toBeGreaterThanOrEqual(6); + expect(parts.length).toBeLessThanOrEqual(7); + + expect(commitEntry).not.contains('\r\n'); + }); }); describe('commitMessage', () => { -- cgit v1.2.3