• 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

12.35
/src/time-picker/inner/inner-time-picker.store.ts
1
import { Injectable } from '@angular/core';
2
import { MiniAction, MiniStore } from 'ngx-tethys/core';
3
import { TinyDate } from 'ngx-tethys/util';
4
import { canChangeHours, canChangeMinutes, canChangeSeconds, canChangeValue, timePickerControls } from '../time-picker-controls.util';
5
import { changeTime, isValidLimit, setTime } from '../time-picker.utils';
6
import { Time, TimeChangeEvent, TimePickerComponentState, TimePickerControls } from './inner-time-picker.class';
7
import { TimePickerConfig } from './inner-time-picker.config';
8

1✔
9
export interface TimePickerState {
10
    value: Date;
11
    config: TimePickerComponentState;
12
    controls: TimePickerControls;
13
}
14

15
export const initialState: TimePickerState = {
16
    value: null,
17
    config: new TimePickerConfig(),
18
    controls: {
19
        canIncrementHours: true,
20
        canIncrementMinutes: true,
21
        canIncrementSeconds: true,
22

23
        canDecrementHours: true,
24
        canDecrementMinutes: true,
1✔
25
        canDecrementSeconds: true,
UNCOV
26

×
27
        canToggleMeridian: true
28
    }
UNCOV
29
};
×
UNCOV
30

×
31
/**
32
 * @internal
33
 */
UNCOV
34
@Injectable()
×
UNCOV
35
export class ThyTimePickerStore extends MiniStore<TimePickerState> {
×
36
    constructor() {
×
37
        super(initialState);
UNCOV
38
    }
×
UNCOV
39

×
40
    @MiniAction()
×
41
    writeValue(value: Date) {
UNCOV
42
        if (value?.getTime() !== this.snapshot.value?.getTime()) {
×
43
            this.setState({ value: value });
44
        }
UNCOV
45
    }
×
UNCOV
46

×
47
    @MiniAction()
×
48
    changeHours(event: TimeChangeEvent, timeZone?: string) {
UNCOV
49
        const state = this.snapshot;
×
UNCOV
50
        if (!canChangeValue(state.config, event) || !canChangeHours(event, state.controls)) {
×
51
            return state;
×
52
        }
UNCOV
53

×
54
        const _newTime = changeTime(state.value, { hour: event.step }, timeZone);
55

UNCOV
56
        if ((state.config.max || state.config.min) && !isValidLimit(state.config, _newTime)) {
×
UNCOV
57
            return state;
×
58
        }
×
59

UNCOV
60
        this.setState({ value: _newTime });
×
61
    }
62

UNCOV
63
    @MiniAction()
×
64
    changeMinutes(event: TimeChangeEvent, timeZone?: string) {
×
65
        const state = this.snapshot;
UNCOV
66
        if (!canChangeValue(state.config, event) || !canChangeMinutes(event, state.controls)) {
×
67
            return state;
68
        }
UNCOV
69

×
UNCOV
70
        const _newTime = changeTime(state.value, { minute: event.step }, timeZone);
×
71

×
72
        if ((state.config.max || state.config.min) && !isValidLimit(state.config, _newTime)) {
UNCOV
73
            return state;
×
UNCOV
74
        }
×
75

76
        this.setState({ value: _newTime });
UNCOV
77
    }
×
UNCOV
78

×
UNCOV
79
    @MiniAction()
×
80
    changeSeconds(event: TimeChangeEvent, timeZone?: string) {
81
        const state = this.snapshot;
82
        if (!canChangeValue(state.config, event) || !canChangeSeconds(event, state.controls)) {
83
            return state;
UNCOV
84
        }
×
UNCOV
85

×
86
        const _newTime = changeTime(
×
87
            state.value,
88
            {
UNCOV
89
                seconds: event.step
×
90
            },
91
            timeZone
1✔
92
        );
93

1✔
94
        if ((state.config.max || state.config.min) && !isValidLimit(state.config, _newTime)) {
95
            return state;
96
        }
97

98
        this.setState({ value: _newTime });
99
    }
1✔
100

101
    @MiniAction()
102
    setTime(value: Time, timeZone?: string) {
103
        const state = this.snapshot;
104
        if (!canChangeValue(state.config)) {
105
            return state;
1✔
106
        }
107

108
        const _newTime = setTime(state.value, value, timeZone);
109
        this.setState({ value: _newTime });
110
    }
111

1✔
112
    @MiniAction()
113
    updateControls(value: TimePickerComponentState, timeZone?: string) {
114
        const state = this.snapshot;
115
        const _newControlsState = timePickerControls(state.value, value);
116
        const _newState: TimePickerState = {
117
            value: state.value,
1✔
118
            config: value,
119
            controls: _newControlsState
120
        };
121

122
        if (state.config.showMeridian !== _newState.config.showMeridian) {
123
            if (state.value) {
1✔
124
                _newState.value = new TinyDate(state.value, timeZone)?.nativeDate;
125
            }
126
        }
127

128
        this.setState(_newState);
129
    }
1✔
130
}
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