Skip to content
Snippets Groups Projects
Select Git revision
  • 4bc7414df2fa67ad51e1512d3ef1ea5ddbb99c1b
  • main default protected
  • renovate/main-docs-renovate-renovate-41.x
  • renovate/main-ghcr.io-renovatebot-base-image-11.x
  • renovate/main-sindresorhus-is-7.x
  • renovate/main-renovatebot-detect-tools-1.x
  • refactor/pin-new-value
  • fix/user-agent
  • feat/37517-base64-private-key
  • next
  • feat/gnupg
  • fix/36615b-branch-reuse-no-cache
  • chore/punycode
  • feat/36219--git-x509-signing
  • feat/structured-logger
  • hotfix/39.264.1
  • feat/skip-dangling
  • gh-readonly-queue/next/pr-36034-7a061c4ca1024a19e2c295d773d9642625d1c2be
  • hotfix/39.238.3
  • refactor/gitlab-auto-approve
  • feat/template-strings
  • 41.122.3
  • 41.122.2
  • 41.122.1
  • 41.122.0
  • 41.121.4
  • 41.121.3
  • 41.121.2
  • 41.121.1
  • 41.121.0
  • 41.120.0
  • 41.119.6
  • 41.119.5
  • 41.119.4
  • 41.119.3
  • 41.119.2
  • 41.119.1
  • 41.119.0
  • 41.118.2
  • 41.118.1
  • 41.118.0
41 results

author.spec.ts

Blame
  • user avatar
    Sergei Zharinov authored and GitHub committed
    b69416ce
    History
    author.spec.ts 1.20 KiB
    import { parseGitAuthor } from './author';
    
    describe('util/git/author', () => {
      describe('parseGitAuthor', () => {
        it('returns null if empty email given', () => {
          expect(parseGitAuthor(undefined as never)).toBeNull();
        });
    
        it('handles a normal address', () => {
          expect(parseGitAuthor('renovate@whitesourcesoftware.com')).not.toBeNull();
        });
    
        it('parses bot email', () => {
          expect(parseGitAuthor('renovate[bot]@users.noreply.github.com')).toEqual({
            address: 'renovate[bot]@users.noreply.github.com',
            name: 'renovate[bot]',
          });
        });
    
        it('parses bot name and email', () => {
          expect(
            parseGitAuthor(
              'renovate[bot] <renovate[bot]@users.noreply.github.com>',
            ),
          ).toEqual({
            address: 'renovate[bot]@users.noreply.github.com',
            name: 'renovate[bot]',
          });
        });
    
        it('escapes names', () => {
          expect(parseGitAuthor('name [what] <name@what.com>')?.name).toBe(
            `name [what]`,
          );
        });
    
        it('tries again and fails', () => {
          expect(parseGitAuthor('foo<foo>')).toBeNull();
        });
    
        it('gives up', () => {
          expect(parseGitAuthor('a.b.c')).toBeNull();
        });
      });
    });