renovate/lib/util/git/author.spec.ts
RahulGautamSingh 3d31fa371d
refactor(lib/util): strict null check for test files (#15812)
* add types for tmp

* expand files in lib/util

* update yarn lock

* Update tsconfig.strict.json

* util/exec

* util/git

* util/http

* Revert "util/exec"

This reverts commit 96cf479a1b.

* update strict.json

* redo util/exec

* revert util/git

* util/merge-confidence

* update util/git

* util/package-rules

* fix util/git

* util/template

* util/

* revert extras

* rm newline

* add tmp back

* apply suggestion from review

* util/cache

* more changes

* Update tsconfig.strict.json

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-06-19 21:17:46 +00:00

43 lines
1.2 KiB
TypeScript

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