/
author.spec.ts
45 lines (44 loc) · 1.41 KB
/
author.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { parseGitAuthor } from './author';
describe('util/git/author', () => {
describe('parseGitAuthor', () => {
it('returns null if empty email given', () => {
expect(parseGitAuthor(undefined)).toBeNull();
});
it('handles a normal address', () => {
expect(parseGitAuthor('renovate@whitesourcesoftware.com')).not.toBeNull();
});
it('parses bot email', () => {
// FIXME: explicit assert condition
expect(parseGitAuthor('renovate[bot]@users.noreply.github.com'))
.toMatchInlineSnapshot(`
Object {
"address": "renovate[bot]@users.noreply.github.com",
"name": "renovate[bot]",
}
`);
});
it('parses bot name and email', () => {
// FIXME: explicit assert condition
expect(
parseGitAuthor('renovate[bot] <renovate[bot]@users.noreply.github.com>')
).toMatchInlineSnapshot(`
Object {
"address": "renovate[bot]@users.noreply.github.com",
"name": "renovate[bot]",
}
`);
});
it('escapes names', () => {
// FIXME: explicit assert condition
expect(
parseGitAuthor('name [what] <name@what.com>').name
).toMatchInlineSnapshot(`"name [what]"`);
});
it('tries again and fails', () => {
expect(parseGitAuthor('foo<foo>')).toBeNull();
});
it('gives up', () => {
expect(parseGitAuthor('a.b.c')).toBeNull();
});
});
});