github.com/argoproj/argo-cd/v3@v3.2.1/ui/src/app/shared/components/urls.test.ts (about)

     1  import {repoUrl, revisionUrl} from './urls';
     2  
     3  function testExample(http: string, ssl: string, revision: string, expectedRepoUrl: string, expectedRevisionUrl: string) {
     4      expect(repoUrl(http)).toBe(expectedRepoUrl);
     5      expect(repoUrl(ssl)).toBe(expectedRepoUrl);
     6      expect(revisionUrl(http, revision)).toBe(expectedRevisionUrl);
     7      expect(revisionUrl(ssl, revision)).toBe(expectedRevisionUrl);
     8      expect(repoUrl(http)).toBe(expectedRepoUrl);
     9      expect(revisionUrl(http, revision)).toBe(expectedRevisionUrl);
    10      expect(revisionUrl(ssl, revision)).toBe(expectedRevisionUrl);
    11  }
    12  
    13  test('github.com', () => {
    14      testExample(
    15          'https://github.com/argoproj/argo-cd.git',
    16          'git@github.com:argoproj/argo-cd.git',
    17          '024dee09f543ce7bb5af7ca50260504d89dfda94',
    18          'https://github.com/argoproj/argo-cd',
    19          'https://github.com/argoproj/argo-cd/commit/024dee09f543ce7bb5af7ca50260504d89dfda94',
    20      );
    21  });
    22  
    23  // for enterprise github installations
    24  test('github.my-enterprise.com', () => {
    25      testExample(
    26          'https://github.my-enterprise.com/my-org/my-repo.git',
    27          'git@github.my-enterprise.com:my-org/my-repo.git',
    28          'a06f2be80a4da89abb8ced904beab75b3ec6db0e',
    29          'https://github.my-enterprise.com/my-org/my-repo',
    30          'https://github.my-enterprise.com/my-org/my-repo/commit/a06f2be80a4da89abb8ced904beab75b3ec6db0e',
    31      );
    32  });
    33  
    34  test('gitlab.com', () => {
    35      testExample(
    36          'https://gitlab.com/alex_collins/private-repo.git',
    37          'git@gitlab.com:alex_collins/private-repo.git',
    38          'b1fe9426ead684d7af16958920968342ee295c1f',
    39          'https://gitlab.com/alex_collins/private-repo',
    40          'https://gitlab.com/alex_collins/private-repo/-/commit/b1fe9426ead684d7af16958920968342ee295c1f',
    41      );
    42  });
    43  
    44  test('bitbucket.org', () => {
    45      testExample(
    46          'https://alexcollinsinuit@bitbucket.org/alexcollinsinuit/test-repo.git',
    47          'git@bitbucket.org:alexcollinsinuit/test-repo.git',
    48          '38fb93957deb45ff546af13399a92ac0d568c350',
    49          'https://bitbucket.org/alexcollinsinuit/test-repo',
    50          'https://bitbucket.org/alexcollinsinuit/test-repo/commits/38fb93957deb45ff546af13399a92ac0d568c350',
    51      );
    52  });
    53  
    54  test('empty url', () => {
    55      expect(repoUrl('')).toBe(null);
    56  });