• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atinc / ngx-tethys / 68ef226c-f83e-44c1-b8ed-e420a83c5d84

28 May 2025 10:31AM UTC coverage: 10.352% (-80.0%) from 90.316%
68ef226c-f83e-44c1-b8ed-e420a83c5d84

Pull #3460

circleci

pubuzhixing8
chore: xxx
Pull Request #3460: refactor(icon): migrate signal input #TINFR-1476

132 of 6823 branches covered (1.93%)

Branch coverage included in aggregate %.

10 of 14 new or added lines in 1 file covered. (71.43%)

11648 existing lines in 344 files now uncovered.

2078 of 14525 relevant lines covered (14.31%)

6.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

18.75
/src/avatar/avatar.pipe.ts
1
import { Pipe, PipeTransform, inject } from '@angular/core';
2
import { ThyAvatarService } from './avatar.service';
3

4
/**
5
 * `\u4e00`: https://www.compart.com/en/unicode/U+4E00
6
 * `\u9fa5`: https://www.compart.com/en/unicode/U+9FA5
7
 */
8
const UNIFIED_IDEOGRAPHS_REGEX = /^[\u4e00-\u9fa5]+$/;
1✔
9

1✔
10
const SET_OF_LETTERS_REGEX = /^[a-zA-Z\/ ]+$/;
11

12
/**
13
 * @private
1✔
14
 */
UNCOV
15
@Pipe({
×
16
    name: 'avatarShortName'
×
17
})
UNCOV
18
export class AvatarShortNamePipe implements PipeTransform {
×
UNCOV
19
    transform(name: string | null | undefined): string {
×
20
        if (!name) {
×
21
            return '';
UNCOV
22
        }
×
23

×
24
        name = name.trim();
×
25

UNCOV
26
        if (UNIFIED_IDEOGRAPHS_REGEX.test(name) && name.length > 2) {
×
27
            return name.slice(name.length - 2);
28
        }
29

1✔
30
        if (SET_OF_LETTERS_REGEX.test(name) && name.indexOf(' ') > 0) {
31
            const words: string[] = name.split(' ');
32
            return (words[0].slice(0, 1) + words[1].slice(0, 1)).toUpperCase();
33
        }
34

35
        return name.length > 2 ? name.slice(0, 2).toUpperCase() : name.toUpperCase();
36
    }
37
}
38

1✔
39
/**
UNCOV
40
 * @private
×
41
 */
×
42
@Pipe({
UNCOV
43
    name: 'avatarBgColor'
×
UNCOV
44
})
×
UNCOV
45
export class AvatarBgColorPipe implements PipeTransform {
×
46
    transform(name: string) {
UNCOV
47
        if (!name) {
×
UNCOV
48
            return;
×
49
        }
50
        const colors = ['#56abfb', '#5dcfff', '#84e17e', '#73d897', '#ff9f73', '#fa8888', '#fb7fb7', '#9a7ef4', '#868af6'];
UNCOV
51
        const nameArray: string[] = name.split('');
×
52
        const code: number =
53
            name && name.length > 0
54
                ? nameArray.reduce(
55
                      function (result, item) {
56
                          result.value += item.charCodeAt(0);
1✔
57
                          return result;
58
                      },
59
                      { value: 0 }
60
                  ).value
61
                : 0;
62
        return {
63
            'background-color': colors[code % 9]
64
        };
65
    }
1✔
66
}
UNCOV
67

×
68
/**
69
 * @private
UNCOV
70
 */
×
71
@Pipe({
72
    name: 'thyAvatarSrc'
73
})
74
export class AvatarSrcPipe implements PipeTransform {
75
    private thyAvatarService = inject(ThyAvatarService);
1✔
76

77
    transform(src: string, size: number) {
78
        return this.thyAvatarService.srcTransform
79
            ? this.thyAvatarService.srcTransform(src, size)
80
            : this.thyAvatarService.avatarSrcTransform(src, size);
81
    }
1✔
82
}
83

84
export const AvatarPipes = [AvatarShortNamePipe, AvatarBgColorPipe, AvatarSrcPipe];
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc