From 053cc4622be44a8589ee25f3d8ea5e31638ff6c8 Mon Sep 17 00:00:00 2001 From: Jonas Kuske Date: Fri, 4 Nov 2022 22:33:48 +0100 Subject: [PATCH] test: add tests for . and .git in repo name --- tests/GitHelper.test.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/GitHelper.test.ts b/tests/GitHelper.test.ts index 6ba3019..48b734a 100644 --- a/tests/GitHelper.test.ts +++ b/tests/GitHelper.test.ts @@ -48,6 +48,40 @@ test('Testing - sanitizeRepoPathSsh from HTTPS', () => { ).toBe('ssh://git@github.com:22/username/repository.git') }) +test('Testing - sanitizeRepoPathSsh - name with dot', () => { + expect( + GitHelper.sanitizeRepoPathSsh(' github.com/owner/site.com ').repoPath + ).toBe('ssh://git@github.com:22/owner/site.com.git') +}) + +test('Testing - sanitizeRepoPathSsh - name with dot and git suffix', () => { + expect( + GitHelper.sanitizeRepoPathSsh(' github.com/owner/site.com.git ') + .repoPath + ).toBe('ssh://git@github.com:22/owner/site.com.git') +}) + +test('Testing - sanitizeRepoPathSsh - name containing ".git"', () => { + expect( + GitHelper.sanitizeRepoPathSsh(' github.com/owner/repo.github ') + .repoPath + ).toBe('ssh://git@github.com:22/owner/repo.github.git') +}) + +test('Testing - sanitizeRepoPathSsh - name containing ".git" and git suffix', () => { + expect( + GitHelper.sanitizeRepoPathSsh(' github.com/owner/repo.github.git ') + .repoPath + ).toBe('ssh://git@github.com:22/owner/repo.github.git') +}) + +test('Testing - sanitizeRepoPathSsh - name containing ".git", git suffix and /', () => { + expect( + GitHelper.sanitizeRepoPathSsh(' github.com/owner/repo.github.git/ ') + .repoPath + ).toBe('ssh://git@github.com:22/owner/repo.github.git') +}) + test('Testing - sanitizeRepoPathSsh - not git suffix', () => { expect( GitHelper.sanitizeRepoPathSsh(' github.com/owner/repository ').repoPath