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

atinc / ngx-tethys / e62d3b10-1466-49c3-aabd-707148681fc8

14 Jun 2024 08:24AM UTC coverage: 90.422%. Remained the same
e62d3b10-1466-49c3-aabd-707148681fc8

push

circleci

minlovehua
feat: use the ngx-tethys/util's coerceBooleanProperty instead of booleanAttribute #INFR-12648

5467 of 6692 branches covered (81.69%)

Branch coverage included in aggregate %.

117 of 120 new or added lines in 66 files covered. (97.5%)

183 existing lines in 46 files now uncovered.

13216 of 13970 relevant lines covered (94.6%)

985.91 hits per line

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

85.29
/src/shared/option/group/option-group.component.ts
1
import {
2
    Component,
3
    HostBinding,
4
    Input,
5
    ContentChildren,
6
    QueryList,
7
    NgZone,
8
    OnDestroy,
9
    AfterContentInit,
10
    ChangeDetectorRef
11
} from '@angular/core';
12
import { Observable, defer, Subject, merge } from 'rxjs';
1✔
13
import { ThyOptionVisibleChangeEvent, ThyOption } from '../option.component';
14
import { take, switchMap, startWith, takeUntil, debounceTime, map } from 'rxjs/operators';
43✔
15
import { THY_OPTION_GROUP_COMPONENT } from '../option.token';
16
import { coerceBooleanProperty } from 'ngx-tethys/util';
17

8✔
18
/**
8✔
19
 * @private
8✔
20
 */
8✔
21
@Component({
8✔
22
    selector: 'thy-option-group',
8✔
23
    templateUrl: './option-group.component.html',
×
UNCOV
24
    providers: [
×
25
        {
UNCOV
26
            provide: THY_OPTION_GROUP_COMPONENT,
×
27
            useExisting: ThySelectOptionGroup
28
        }
29
    ],
30
    standalone: true
8✔
31
})
8✔
32
export class ThySelectOptionGroup implements OnDestroy, AfterContentInit {
33
    _hidden = false;
34
    @Input({ transform: coerceBooleanProperty })
35
    @HostBinding(`class.disabled`)
8✔
36
    thyDisabled: boolean;
11✔
37

38
    @HostBinding('class.thy-option-item-group') _isOptionGroup = true;
5✔
39

10✔
40
    @HostBinding('class.thy-select-option-group-hidden')
1✔
41
    get hidden(): boolean {
42
        return this._hidden;
43
    }
5✔
44

1✔
45
    @Input() thyGroupLabel: string;
46

47
    @ContentChildren(ThyOption) options: QueryList<ThyOption>;
4✔
48

49
    _destroy$: Subject<void> = new Subject<void>();
50

51
    optionVisibleChanges: Observable<ThyOptionVisibleChangeEvent> = defer(() => {
5✔
52
        if (this.options) {
5✔
53
            return merge(...this.options.map(option => option.visibleChange));
54
        }
55
        return this._ngZone.onStable.asObservable().pipe(
56
            take(1),
8✔
57
            switchMap(() => this.optionVisibleChanges)
8✔
58
        );
59
    }) as Observable<ThyOptionVisibleChangeEvent>;
1✔
60

61
    constructor(private _ngZone: NgZone, private cdr: ChangeDetectorRef) {}
62

63
    ngAfterContentInit() {
1✔
64
        this.options.changes.pipe(startWith(null), takeUntil(this._destroy$)).subscribe(() => {
65
            this._resetOptions();
66
        });
67
    }
68

69
    _resetOptions() {
70
        const changedOrDestroyed$ = merge(this.options.changes, this._destroy$);
71
        merge(...this.options.map(option => option.visibleChange))
1✔
72
            .pipe(
73
                takeUntil(changedOrDestroyed$),
74
                debounceTime(10),
75
                map((event: ThyOptionVisibleChangeEvent) => {
76
                    const hasOption = this.options.find(option => {
77
                        if (!option.hidden) {
78
                            return true;
79
                        }
80
                    });
81
                    if (hasOption) {
82
                        return false;
83
                    } else {
84
                        return true;
85
                    }
86
                })
87
            )
88
            .subscribe((data: boolean) => {
89
                this._hidden = data;
90
                this.cdr.markForCheck();
91
            });
92
    }
93

94
    ngOnDestroy() {
95
        this._destroy$.next();
96
        this._destroy$.complete();
97
    }
98
}
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